Skip to content
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

Prevent undefined property warnings during search. #400

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

peterwilsoncc
Copy link
Contributor

@peterwilsoncc peterwilsoncc commented Sep 26, 2024

Description of the Change

To avoid modifying the search query clause twice, the redirect term is discarded after the WHERE clause is generated.

The use of unset() triggers warnings as the second call to the filter is attempting to access an undefined property. This changes the code to set the search term to false to prevent the second and subsequent runs of the filter.

Closes #399

How to test the Change

  1. Enable all logging of errors in your wp-config.php file:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', true );
    define( 'WP_DEBUG_LOG', true );
  2. Configure the site to run on PHP 8.0+ (this is when the error level became a warning)
  3. Create a redirect
  4. Search redirects
  5. Check the logs to ensure a warning is not recorded. On single site installs the log is located in the default wp-content folder.
    • on trunk a warning will be thrown
    • on this branch no warning will be thrown

Changelog Entry

Fixed - Prevent undefined property warnings when searching redirects.

Credits

Props @chermant, @Sidsector9, @peterwilsoncc

Checklist:

Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @peterwilsoncc!

@Sidsector9 Sidsector9 merged commit f71b408 into develop Sep 26, 2024
16 checks passed
@Sidsector9 Sidsector9 deleted the fix/399-undefined-property branch September 26, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined property: SRM_Post_Type::$redirect_search_term
2 participants