Opened 15 years ago
Last modified 6 years ago
#14493 accepted enhancement
do_enclose() can ping the same URL many times, can't filter URLs to ping
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0.1 |
Component: | Feeds | Keywords: | needs-patch |
Focuses: | Cc: |
Description
If the same URL is included in a post several times, do_enclose() can check that URL for inclusion as a possible enclosure several times.
Additionally, there's no way to filter what URLs do_enclose() should ping for possible inclusion as enclosures.
Attached adds an array_unique() call to do_enclose().
Attached adds a do_action_ref_array( 'pre_enclose', array( &$post_links, &$pung ) )
hook to allow filtration of URLs to ping. (Matches the pre_ping hook.)
do_enclose() has several more problems this patch addresses.
- Correct non-functional DELETE FROM postmeta query (bad use of wpdb::prepare()).
- Use like_escape() in several LIKE queries.
- Add an
apply_filters( 'enclosure_mime_types', array( 'video', 'audio' ) )
hook. - Currently do_enclose() doesn't allow root URLs as enclosures (e.g. http://example.com/), only URLs with a non-trivial path or query. Move that functionality to the new pre_enclose filter.
- Efficiency improvements in conditional logic.
- Clean up code by reducing control structure nesting depth.
Attachments (1)
Change History (10)
#3
@
14 years ago
- Keywords 3.2-early added
- Milestone changed from 3.1 to Future Release
- Type changed from defect (bug) to enhancement
Let's do this early 3.2. Probably too late for 3.1.
#4
@
14 years ago
Was going to open a new ticket but I think it can be addressed here:
do_enclose()
does not check that the response to wp_get_http_headers()
was good (i.e., HTTP 200) before trying to process it. That means that if you happen to have a link that is either broken or redirected (301), it doesn't realise this and still tries to parse the result, resulting in PHP notices (e.g., missing content-length header).
Two things:
(1) We should at least be checking for a 200 response
(2) Maybe we could be clever and follow 301 redirects. Seeing as there are so many shortlinks floating about everywhere, I think this would greatly increase the number of hits for do_enclose()
#6
@
12 years ago
Said cleanup is in http://core.trac.wordpress.org/attachment/ticket/20417/20417.3.diff.
Suggested test post content: