Edit-Flow icon indicating copy to clipboard operation
Edit-Flow copied to clipboard

Fix undefined hook_suffix

Open mikeyarce opened this issue 4 years ago • 2 comments

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

  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.

mikeyarce avatar Jun 10 '21 22:06 mikeyarce

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.

mikeyarce avatar Jun 11 '21 15:06 mikeyarce

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 https://github.com/Automattic/Edit-Flow/issues/654#issuecomment-860476813

htdat avatar Jun 14 '21 07:06 htdat

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

rebeccahum avatar Oct 03 '23 21:10 rebeccahum