10up / safe-redirect-manager

A simple HTTP redirection plugin for WordPress.
https://wordpress.org/plugins/safe-redirect-manager
GNU General Public License v2.0
314 stars 82 forks source link

Undefined property: SRM_Post_Type::$redirect_search_term #399

Closed chermant closed 1 month ago

chermant commented 1 month ago

Describe the bug

Hello,

There is an "Undefined property: SRM_Post_Type::$redirect_search_term" when I try to use the search engine on the redirect listing page.

The issue is from the inc/classes/class-srm-post-type.php at line 142 : if ( $this->redirect_search_term ) {

The following code is solving this issue by adding a ! empty : if ( ! empty( $this->redirect_search_term ) ) {

Is it possible to add it on the plugin please ?

Regards, Clément.

Steps to Reproduce

  1. Go to Settings > Safe Redirect Manager
  2. Write a term of the search field
  3. Clic on "Search Redirect"
  4. See the Warning

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

WordPress : 6.6.2 PHP: 8.2 Framework: Themosis

Code of Conduct

Sidsector9 commented 1 month ago

Hi @chermant I am unable to reproduce the warning following your steps. Can you share the whole stack trace? Can you also share the version of the plugin?

chermant commented 1 month ago

Hello @Sidsector9 ,

Thank you for the response !

We are using the plugin in the latest version 2.2.0.

Here is the stack trace:

content/plugins/safe-redirect-manager/inc/classes/class-srm-post-type.php:142
    SRM_Post_Type->filter_search_clauses()
    wp-includes/class-wp-hook.php:324
    apply_filters_ref_array('posts_clauses')
    wp-includes/class-wp-query.php:2955
    WP_Query->get_posts()
    wp-includes/class-wp-query.php:3852
    WP_Query->query()
    wp-includes/class-wp-theme-json-resolver.php:517
    WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles()
    wp-includes/class-wp-theme-json-resolver.php:557
    WP_Theme_JSON_Resolver::get_user_data()
    wp-includes/class-wp-theme-json-resolver.php:673
    WP_Theme_JSON_Resolver::get_merged_data()
    wp-includes/global-styles-and-settings.php:80
    wp_get_global_settings()
    wp-includes/fonts/class-wp-font-face-resolver.php:29
    WP_Font_Face_Resolver::get_fonts_from_theme_json()
    wp-includes/fonts.php:46
    wp_print_font_faces()
    wp-includes/class-wp-hook.php:324
    do_action('admin_print_styles')
    wp-admin/admin-header.php:132
Sidsector9 commented 1 month ago

Thanks for sharing! Nothing unusual in the trace. What is surprising is that $redirect_search_term exists as a class property, I don't understand why it would be undefined at all 🤔

@10up/open-source-practice can you try reproducing this issue?

peterwilsoncc commented 1 month ago

@Sidsector9 I was able to reproduce and have created PR #400 to resolve.