I don't know exactly why, but TrackBack did not ping other sites at all until I applied the attached patch.

Basically, it's not required to ping other sites in a shutdown function. It is possible that TrackBack's shutdown function is overridden by Devel module's shutdown function. Anyway, I see no point for executing pings to other sites in a shutdown function. This also opens the door for showing ping results after submitting a content.

Additionally, I've removed all calls to db_lock_table() and db_unlock_tables(). I see no reason for locking tables in this module.

Comments

zorac’s picture

Really?
In the PHP manual, "Multiple calls to register_shutdown_function() can be made".

zorac’s picture

Status: Needs review » Postponed (maintainer needs more info)
sun’s picture

Status: Postponed (maintainer needs more info) » Active

Counter question: Are there any reasons why the code should not be cleaned up in the proposed way?

Using a shutdown_function for something that can be done immediately only complicates the script and reduces compatibility.

Brandon_Berg’s picture

Do you have the pathauto module installed? I've been running up against a similar problem as described here, and I've been able to get trackbacks to work by either disabling the pathauto module or by using your approach of calling _trackback_send directly.

Update: I think I've discovered a problem with this solution: If you try to track back to a post on the same site when initially submitting the node, then you'll send the trackback before pathauto is applied, and the trackback will end up with a URL like http://www.yoursite.com/node/1234. If you first submit the node without the trackback and then edit the node and add the trackback, it will work correctly, since pathauto will already have been applied (when the node was created).

Also, note that the forum post I link to above contains additional insight into the cause of this bug. Short version: If you have the pathauto module installed and enabled, calling _trackback_send() will result in all the nodeapi hooks being called for the "view" operation. pathauto_nodeapi calls _pathauto_include, which calls require_once() to load pathauto.inc, and for some reason this fails.

sun’s picture

Title: Ping not working at all » Ping not working with Pathauto
Status: Active » Needs review

Yes, I've installed Pathauto. I'd guess that most sites have.

Your findings make perfectly sense to me. I guess, one does not see an error, because the output has already been sent.

I was already a bit confused, why no one else experienced this bug. So, thanks for investigating this further!
Changing title and status accordingly.

zorac’s picture

@Brandon_Berg: I've examined this problem. It seems to be a PHP's bug that the current directory has be changed in the shutdown function. I'll commit new develop version of trackback module. It's using hook_exit() function instead of the shutdown function.

sun’s picture

@zorac: Could you please post a patch here, so we are able to test the changes before they are committed?

zorac’s picture

@sun: It was committed. Please use development snapshot.

sun’s picture

Status: Needs review » Needs work

That is considered bad practice. See http://drupal.org/patch for details about Drupal's process and guidelines about patches.

Also, your committed code looks quite weird. You've implemented trackback_exit() as a private function in trackback_nodeapi(). That will not only work by coincidence, but also does not adhere to Drupal's coding standards.

It would be great if you would adopt common practices of the Drupal community. Btw, by doing this, you will save yourself from unnecessary issues in the queue, and also allow other developers to help out in the development of TrackBack module.

gnassar’s picture

Getting white screens on any node insert or update. The error:

Cannot redeclare trackback_exit() (previously declared in /public_html/sites/default/modules/trackback/trackback.module:345) in /public_html/sites/default/modules/trackback/trackback.module on line 344

I'd create another issue, except this seems directly and inescapably related to the patch submitted due to this issue.

It is a white-screen, so tempted to up priority to critical (now that this is live in dev), but I'd imagine somebody else would've seen this by now, so it must be something unique to my configuration. Will do more digging. Don't want to submit a patch until I 1) figure out what other module is not playing nice with it or 2) I understand the logic behind making trackback_exit private, which I don't yet.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB

Please test attached patch.

gnassar’s picture

Yeah, after looking at it for a minute or two, I saw no reason why the declaration couldn't be placed outside the function either (as the patch does).

The five-second analysis is that it does fix the white screen. And the patch is logical, IMHO. Will report back if I run into anything interesting.

sun’s picture

Status: Needs review » Reviewed & tested by the community
thepanz’s picture

Version: 5.x-1.4 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

Seems to be fixed by Zorac CVS commits:
D6: http://drupal.org/cvs?commit=116148
D5: http://drupal.org/cvs?commit=116147

Re-open this issue in case of errors.
Regards

sun’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Fixed » Reviewed & tested by the community

See #9 and #11. Also look at the dates.

thepanz’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

You're right Sun, I didn't check dates! :(
I committed it into latest 5.x-dev version ( but I don't have a D5 test site to test it :| )

Seems that 6.x version is already fixed (correct me if I'm wrong)

thepanz’s picture

Status: Patch (to be ported) » Fixed

Wrong issue Status: corrected

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.