Edit-Flow
Edit-Flow copied to clipboard
Fix undefined hook_suffix
Description
Fixes https://github.com/Automattic/Edit-Flow/issues/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
- Go to Edit Flow -> User Groups
- Click Quick Edit
- Make a change
- Click "Update User Group"
- 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.
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.
I saw that adding the
screenargument 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
screenargument? 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 https://github.com/Automattic/Edit-Flow/issues/654#issuecomment-860476813
Closing since it looks like it's been resolved per the trac ticket.