-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetpack Search: Ensure that the widget always persists an array #23476
Comments
The error is reported in 4864304-zen. Not sure yet if it's useful to check for any plugin conflicts, I'm happy to follow up with the user about this if that's useful. |
The error suggests the option value stored in
I looked at all the places where we change the value of Other possibilities could be, the option value is changed elsewhere.
I'll close the issue for now, unless more cases come in. Thanks. |
I've just run into this. Actually I have no idea how long it's been going on for but at the very least since December 4th (that's as far back as my logs go). I last updated Jetpack on December 5th, so it's not 'new'. My guess is that it has to do with the fact that the 3rd and 4th options (categories and tags) are NOT present on all post types, and it's just flailing miserably when that happens. Edit: Nope, still happening :(
The only part of MY code that touches Jetpack search is this:
Source: https://jetpack.com/support/search/inline-search/customize-inline-search/#code-facets However the error happens even with my code disabled. |
Support References This comment is automatically generated. Please do not edit it.
|
Debugging the error is a bit challenging, as the reported error was 2 years ago and the version of WordPress is unknown. One could make some guesses based on changelog, but generally, this is the code section, with line numbers potentially shifted a bit, as there have been commits in function is_active_widget( $callback = false, $widget_id = false, $id_base = false, $skip_inactive = true ) {
global $wp_registered_widgets;
$sidebars_widgets = wp_get_sidebars_widgets();
if ( is_array( $sidebars_widgets ) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( $skip_inactive && ( 'wp_inactive_widgets' === $sidebar || str_starts_with( $sidebar, 'orphaned_widgets' ) ) ) {
continue;
}
if ( is_array( $widgets ) ) {
foreach ( $widgets as $widget ) {
if ( ( $callback && isset( $wp_registered_widgets[ $widget ]['callback'] ) && $wp_registered_widgets[ $widget ]['callback'] === $callback ) || ( $id_base && _get_widget_id_base( $widget ) === $id_base ) ) {
if ( ! $widget_id || $widget_id === $wp_registered_widgets[ $widget ]['id'] ) {
return $sidebar;
}
}
}
}
}
}
return false;
} In the original report, the error It is likely the file has since shifted down one or two lines, with the suspected code block being: if ( ( $callback && isset( $wp_registered_widgets[ $widget ]['callback'] ) && $wp_registered_widgets[ $widget ]['callback'] === $callback ) || ( $id_base && _get_widget_id_base( $widget ) === $id_base ) ) {
if ( ! $widget_id || $widget_id === $wp_registered_widgets[ $widget ]['id'] ) { At the core, the problem is likely coming from the reality that this code segment is in a The first of these lines checks that the desired value is set before accessing it:
e.g., is there a global widget which has a callback set? The second line does not check the same way -- it makes an assumption that if a callback is set, then so an
Therefore, it would likely resolve Mika's warning to verify The original warning may be the same thing, but generally, if being thorough, one might verify that This may be specific to Jetpack, but more generally seems to be a result of accessing data expected in a global based on a local list of widgets before verifying the global data takes the form expected from the last time the sidebar was saved. One might expect this to occur in cases where the global registered widgets have changed in structure or do not have a widget ID defined. e.g., perhaps a widget was removed, a JetPack feature turned off when it previously was on, etc. |
Interestingly this has moved on:
|
I'm seeing the same issue as @Ipstenu, actually with two Jetpack widgets (Top Posts and Search). I did some digging and I believe this issue stems from
I've tested locally with moving the
Should we open a new issue about this? |
Thanks for the feedback @davisshaver. I reopened the issue and it's now under our radar; however we are not sure about the timeline to fix it. Thanks for proposing the fix, which is very helpful. |
hi 👋 |
We got the report for the same from one more user in the forum. |
Impacted plugin
Jetpack
Steps to Reproduce
Reported by one of our customers; exact repro steps are unknown.
What actually happened
It looks like a Jetpack Search widget was persisted into the options table as a non-array value, resulting in this warning notice being thrown:
cc @StefMattana @kangzj
The text was updated successfully, but these errors were encountered: