#2269 closed defect (bug) (fixed)
pre_ping hook is placed poorly... needs to move outside foreach() loop
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0 |
Component: | Administration | Keywords: | bg|has-patch bg|commit |
Focuses: | Cc: |
Description
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)); endif; endforeach;
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
links.
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.
Fix for SVN trunk