Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2269 closed defect (bug) (fixed)

pre_ping hook is placed poorly... needs to move outside foreach() loop

Reported by: markjaquith's profile markjaquith Owned by: markjaquith's profile markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Administration Keywords: bg|has-patch bg|commit
Focuses: Cc:


pre_ping is a new hook for WordPress 2.0

Its placement seems very bizarre to me. Observe:

 	foreach($post_links_temp[0] as $link_test) :
 		if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
 				&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
 			$test = parse_url($link_test);
 			if (isset($test['query']))
 				$post_links[] = $link_test;
 			elseif(($test['path'] != '/') && ($test['path'] != ''))
 				$post_links[] = $link_test;
 			do_action('pre_ping',  array(&$post_links, &$pung));

The do_action() is inside of the foreach loop, which means that it
gets run multiple times. But it passes a reference to the entire
array of $post_links and $pung URIs each time it is run.

So if an entry has these three links: http://site1 http://site2 and
http://site3 ... something using that hook would first get http://
site1, then get http://site1 and http://site2, and then get all three

Is there a reason it was placed here? Seems to me that the place
place to put it would be AFTER the foreach loop. It makes sense to
me in that context.

It's very likely that no one is using this hook, as WordPress 2.0 has
only been out a few days.

Attachments (1)

pre_ping_FIX.diff (679 bytes) - added by markjaquith 18 years ago.
Fix for SVN trunk

Download all attachments as: .zip

Change History (4)

18 years ago

Fix for SVN trunk

#1 @markjaquith
18 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

#2 @ryan
18 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [3427]) Trigger pre_ping action outside of loop. Props Mark Jaquith. fixes #2269

#3 @(none)
18 years ago

  • Milestone 2.0.1 deleted

Milestone 2.0.1 deleted

Note: See TracTickets for help on using tickets.