#20379 closed defect (bug) (invalid)
dashboard_incoming_links fails to update when 'home' changes, so google rss is wrong
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | Feeds | Keywords: | |
Focuses: | Cc: |
Description
When the user changes 'home', the wp_option 'dashboard_widget_options' is updated. But WP fails to update it completely, so the default Google RSS syndication URL is broken.
The borked value is:
dashboard_widget_options: dashboard_incoming_links: url
which is of the form
The string at the end, example.com, is supposed to change but it does not.
Here is the problem.
(Trunk has the same code as the current ver. 3.3.1.)
http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/dashboard.php#L59
constructs 'url' as follows, expanded for readability:
'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
Since 'url' is already set, it never changes! The value of get_option('home') is not used.
This code block is only reached when 'home' has changed, or on initial setup, so it does not make much sense to ignore 'home'.
I'm not sure if there is any reason to keep the tertiary. Solution 1 below is the simple fix.
Solution 2 is a heuristic fix to handle the case where a plugin or theme has updated the database, instead of using the filter. It mimics the current (possibly wrong) behavior in that case.
Solution 1:
$widget_options['dashboard_incoming_links'] = array( ... 'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
Solution 2:
$url_prefix = 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:'; $url = $url_prefix . trailingslashit( get_option( 'home' ) ); if ( isset ( $widget_options['dashboard_incoming_links']['url'] ) ) { if ( 0 !== strpos( $widget_options['dashboard_incoming_links']['url'], $url_prefix ) ) { $url = $widget_options['dashboard_incoming_links']['url']; } } $widget_options['dashboard_incoming_links'] = array( ... 'url' => apply_filters( 'dashboard_incoming_links_feed', $url ),
The importance of this bug is twofold:
- No clear workaround for the user, even with basic PHPMyAdmin skills. The incorrect value is in a serialized array in the table 'wp_options'.
- Users may not realize the feed is borked, since there is no Dashboard UI. I think there used to be. The WP forums have several 5-year old threads about it.
By the way, $num_items never changes by default. It could only be updated by plugins or themes, and Solution 2 assumes they know what they are doing there too.
Change History (8)
#2
@
13 years ago
Replying to kitchin:
- No clear workaround for the user, even with basic PHPMyAdmin skills. The incorrect value is in a serialized array in the table 'wp_options'.
As a workaround, one can fix the link by simply clicking Configure in the Incoming Links widget header. Number of items can also be changed there.
- Users may not realize the feed is borked, since there is no Dashboard UI. I think there used to be. The WP forums have several 5-year old threads about it.
Not sure what you mean by "Dashboard UI".
#3
@
13 years ago
Thanks for the quick reply. I was looking at Dashboard/Widgets, not on the Dashboard home.
Do you think it should change when 'home' changes?
#4
@
13 years ago
Otherwise, I can add the info about how to use the Dashboard UI to http://codex.wordpress.org/Moving_WordPress
#5
@
12 years ago
Instead I updated http://codex.wordpress.org/Changing_The_Site_URL
I still think this is a bug. The instructions to update this default option are so obscure I imagine most people will miss it when changing a Site URL. And WP already has the code to construct the default URL reflecting the Site URL.
Here's what I put in codex:
Fix the Incoming Links URL. This one is easy to miss. Look on the main Dashboard screen, at Incoming Links. Hover over the area to the right of "Incoming Links" to reveal the "Configure" link. Edit the URL to reflect the new site address.
Here is a plugin I wrote implementing Solution 2. I only tested it in the default case though.
http://pastebin.com/UuDGqm3G