This is more of a follow up to #339929: Move node links into $node->content

It moves node "read more" link to $node->content instead of now comments-only hook_link. For reference, this is explained in the upgrade docs.

Comments

AmrMostafa’s picture

StatusFileSize
new1.71 KB

This makes it node->build_more aware, this will make node_feed() simpler.

AmrMostafa’s picture

StatusFileSize
new1.7 KB

... and this is the correct patch :)

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks like the right fix to me. thanks.

dries’s picture

If hook_link is comments only now, so we consider renaming it for clarity? That could be done in another patch, but I wanted to bring it up now so we can create an issue for it if necessary.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Hm. Grepping for module_invoke_all('link'" reveals that this is present in poll.module as well. You can't have teasers in polls though, which is probably why this link isn't showing up there now. And I agree with Dries that if hook_link is indeed intended to be only for comments (and this is not the sign of a larger bug), then it probably makes sense to rename hook_links() to something more descriptive (or ditch it altogether), so I created #451272: Rename or remove or do *something* with hook_link() to deal with all of that.

As for this patch...

This:

+  if ($teaser && $node->teaser && !empty($node->readmore) && in_array($node->build_mode, array(NODE_BUILD_NORMAL, NODE_BUILD_RSS))) {

is way less legible than the code before it. I had to read that about 3 times to get what it was saying. This at the very least needs a comment; possibly encapsulating into a function if it's something we're going to end up checking more than once ever.

Also, if "read more" has been broken for 3+ months, then GUESS WHAT that means we need? ;) Let's add a few tests to ensure that the read more link shows up, that when clicked the body is found, etc. I'm kind of surprised there isn't a test for this yet. Hm. Also, while we're at it, let's add a test for the RSS special-casing introduced in this patch, too.

sun’s picture

Hm. This patch makes me start to question much.

1) Is hook_links a relict of the past?

2) That condition test and $href munging sucks. We want separate links for each build mode.

3) Ideally, the admin is able to configure (i.e. enable/disable/add custom) links per build mode.

4) On a related note, $object->readmore should now not only dependent on build mode, but also, whether there is actually more to display.

AmrMostafa’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new6.19 KB

Here is a new patch, it should address your comments so far, with tests :)

@webchick: for Poll, I've created/updated separate issues:

  1. #372650: Poll node is not displayed when poll block is displayed as well
  2. #453588: Poll use for hook_link no longer applies
  3. #453554: Poll block is always rendered as the node
AmrMostafa’s picture

StatusFileSize
new7.48 KB

Better patch, more cleanup and tests for RSS.

AmrMostafa’s picture

StatusFileSize
new7.47 KB

Comment typo.

dries’s picture

I'm delegating this patch to sun (or webchick, obviously). sun can let me know when this is ready to go in. (@sun, if you don't want to be this patch's champion, just let us know.)

stella’s picture

Status: Needs review » Needs work

There are some minor issues to be fixed:

  • There should be no trailing spaces in your code.
  • The Drupal coding standard is to use "elseif" rather than "else if"
  • @see should always be in a function comment block rather than as an inline comment

Also shouldn't we be using drupal_strlen() rather than strlen() so we can correctly count the number of characters of UTF-8 strings?

Cheers,
Stella

Tor Arne Thune’s picture

Version: 7.x-dev » 8.x-dev

This is no longer a valid issue as far as I can see, as hook_link no longer exists, for example, and I can find little code in the patch that corresponds to the current state of core. Confirmation, please?

jody lynn’s picture

Status: Needs work » Closed (works as designed)

Confirmed, no longer an issue.