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

PHP deprecated warnings #7604

Closed
westonruter opened this issue Aug 31, 2023 · 3 comments · Fixed by #7614
Closed

PHP deprecated warnings #7604

westonruter opened this issue Aug 31, 2023 · 3 comments · Fixed by #7614
Assignees
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.
Milestone

Comments

@westonruter
Copy link
Member

Bug Description

I noticed on the AMP report on plugintests.com that there are 5 deprecation warnings being reported:

[29-Aug-2023 18:22:43 UTC] PHP Deprecated:  strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 1144
[29-Aug-2023 18:22:43 UTC] PHP Deprecated:  stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 1151
[29-Aug-2023 18:22:43 UTC] PHP Deprecated:  stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 1154
[29-Aug-2023 18:22:43 UTC] PHP Deprecated:  str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 1161
[29-Aug-2023 18:22:43 UTC] PHP Deprecated:  str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 1164

It's not clear to me whether core is actually at fault or not, as the stack traces don't indicate how the AMP plugin is involved. But it would be good to investigate.

Expected Behaviour

No deprecation warnings should be reported for the plugin.

Screenshots

No response

PHP Version

No response

Plugin Version

latest

AMP plugin template mode

Standard, Transitional, Reader

WordPress Version

No response

Site Health

No response

Gutenberg Version

No response

OS(s) Affected

No response

Browser(s) Affected

No response

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

@westonruter westonruter added the Bug Something isn't working label Aug 31, 2023
@thelovekesh
Copy link
Collaborator

thelovekesh commented Sep 3, 2023

@westonruter Reported deprecation warnings are caused by the AMP plugin. Even in the PHPUnit tests CI, we thought all deprecation warnings were due to the GB plugin, but they were due to the AMP plugin as well.

add_query_arg(
$redirect_query_args,
get_edit_post_link( $post_id, 'raw' )
)

get_edit_post_link( $post_id, 'raw' ) always returns null, and later these deprecation warnings are generated within add_query_arg(). Seems like at this point of execution user does not have permission to edit the post hence get_edit_post_link( $post_id, 'raw' ) is returning null.

EDIT:
The above one is only responsible for deprecation warnings in unit tests.

@thelovekesh
Copy link
Collaborator

The deprecation warnings reported by plugintests are visible on the AMP > Error Index page with PHP 8.1.

Deprecation Warnings

image

Stack trace
Array
(
    [0] => Array
        (
            [file] => /app/public/core-dev/build/wp-admin/includes/class-wp-list-table.php
            [line] => 1782
            [function] => handle_row_actions
            [class] => WP_Terms_List_Table
            [type] => ->
        )

    [1] => Array
        (
            [file] => /app/public/core-dev/build/wp-admin/includes/class-wp-terms-list-table.php
            [line] => 352
            [function] => single_row_columns
            [class] => WP_List_Table
            [type] => ->
        )

    [2] => Array
        (
            [file] => /app/public/core-dev/build/wp-admin/includes/class-wp-terms-list-table.php
            [line] => 260
            [function] => single_row
            [class] => WP_Terms_List_Table
            [type] => ->
        )

    [3] => Array
        (
            [file] => /app/public/core-dev/build/wp-admin/includes/class-wp-list-table.php
            [line] => 1618
            [function] => display_rows_or_placeholder
            [class] => WP_Terms_List_Table
            [type] => ->
        )

    [4] => Array
        (
            [file] => /app/public/core-dev/build/wp-admin/edit-tags.php
            [line] => 611
            [function] => display
            [class] => WP_List_Table
            [type] => ->
        )

)

Inside handle_row_actions it generates an edit link for a given term ID which then checks if the current user can edit a particular term ID with edit_term capability. In our case we are using custom capabilities hence it passes null to the add_query_arg() which then generates deprecation warnings.

@westonruter westonruter added this to the v2.5.0 milestone Oct 25, 2023
@pavanpatil1
Copy link

QA Passed ✅

Cross-verified the issue and it is working fine. With the WordPress 6.3 the warnings are still visible. These warnings have been successfully addressed in WordPress version 6.4 through this Pull Request - WordPress/wordpress-develop#5198

Before fix After fix
image image

@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants