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

Fix undefined hook_suffix #666

Closed
wants to merge 4 commits into from
Closed

Conversation

mikeyarce
Copy link
Member

Description

Fixes #654

Without a specified screen when extending WP_List_Table - the function convert_to_screen will return a PHP Warning due to an undefined hook suffix which is needed to identify the current screen

Steps to Test

  1. Go to Edit Flow -> User Groups
  2. Click Quick Edit
  3. Make a change
  4. Click "Update User Group"
  5. You should see a PHP Warning like this: [07-Jun-2021 17:34:31 UTC] PHP Warning: Undefined array key "hook_suffix" in /wp-admin/includes/class-wp-screen.php on line 223

Apply this PR and then do the steps again and you won't see the PHP Warning any longer.

Without a specified `screen` when extending `WP_List_Table` - the function `convert_to_screen` will return a PHP Warning due to an undefined hook suffix which is needed to identify the current screen
@mikeyarce mikeyarce requested a review from htdat June 10, 2021 22:39
Copy link
Member

@htdat htdat left a comment

Choose a reason for hiding this comment

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

I dug into this issue further, and I found out that there is nothing wrong with the current implementation of Edit Flow.

It turns out the error itself is a bug of WordPress core.
https://core.trac.wordpress.org/ticket/49089

That said, this PR helps overcome the core bug above.

@@ -1729,7 +1729,8 @@ function __construct() {
parent::__construct( array(
'plural' => 'custom statuses',
'singular' => 'custom status',
'ajax' => true
'ajax' => true,
'screen' => 'ef-custom-status-settings',
Copy link
Member

@htdat htdat Jun 11, 2021

Choose a reason for hiding this comment

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

Actually, any value for screen different from null will get you through this error.

@mikeyarce
Copy link
Member Author

I dug into this issue further, and I found out that there is nothing wrong with the current implementation of Edit Flow.

It turns out the error itself is a bug of WordPress core.
https://core.trac.wordpress.org/ticket/49089

That said, this PR helps overcome the core bug above.

Good find!

I saw that adding the screen argument was how this was addressed in the past with similar issues:
https://core.trac.wordpress.org/changeset/22085

Do you think there's anything we can suggest to Core that might improve this so that you don't need the screen argument? It seems like it might only be an issue for AJAX requests.

@htdat
Copy link
Member

htdat commented Jun 14, 2021

I saw that adding the screen argument was how this was addressed in the past with similar issues:
https://core.trac.wordpress.org/changeset/22085

I am pretty sure that it does not help to fix the issue as WP_List_Table class can be still initialized with screen = null, and the issue is still there.

Do you think there's anything we can suggest to Core that might improve this so that you don't need the screen argument? It seems like it might only be an issue for AJAX requests.

Yeah, I tried to find a simple way to replicate this issue last week but I failed somehow. I think this week with a fresh mind helps me to understand the root cause. I am going to write it down in #654 then post it to the trac issue.

Update: I wrote up this comment to explain the core issue #654 (comment)

@rebeccahum
Copy link
Contributor

Closing since it looks like it's been resolved per the trac ticket.

@rebeccahum rebeccahum closed this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Quick Edit in User Groups PHP Error
3 participants