WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 12 months ago

#29933 closed defect (bug) (invalid)

Undefined index: hook_suffix on WP_List_Table

Reported by: z43 Studio Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Administration Keywords:
Focuses: administration Cc:

Description (last modified by SergeyBiryukov)

Using WP_List_Table subclasses in a plugin, I am receiving this error:

( ! ) Notice: Undefined index: hook_suffix in ~~~~/wp-admin/includes/screen.php on line 388
Call Stack
#	Time	Memory	Function	Location
1	0.0006	297776	{main}( )	../admin.php:0
2	0.2897	20948360	do_action( )
3	0.2940	21103488	call_user_func_array:{~~~~/wp-includes/plugin.php:505} ( )	../plugin.php:505
4	0.2940	21103680	~~~~~~~~~~~~~~~
5	0.2989	21469928	~~~~~~~~~~~~~~~
6	0.2989	21470832	WP_List_Table->__construct( )	../my-table-subclass.php:20
7	0.2989	21471512	convert_to_screen( )	../class-wp-list-table.php:101
8	0.2989	21471920	WP_Screen::get( )	../template.php:2079

Change History (3)

#1 @SergeyBiryukov
6 years ago

  • Component changed from Plugins to Administration
  • Description modified (diff)
  • Focuses administration added; performance removed
  • Keywords reporter-feedback added

Could you provide a piece of code to reproduce the issue?

$hook_suffix is only set after admin_init, you're probably calling WP_Screen::get() too early.

#2 @chriscct7
5 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

No reporter feedback in over a year. Closing as invalid

#3 @samjco
12 months ago

@SergeyBiryukov @chriscct7 @z43-studio
I was getting the same error when I move my Wp List table to the frontend
Notice: Undefined index: hook_suffix in ..../wp-admin/includes/class-wp-screen.php on line 213

I fixed it by replacing

$id = $GLOBALS['hook_suffix'];

with

$id = isset($GLOBALS['hook_suffix']) ? $GLOBALS['hook_suffix'] : "";

Note: See TracTickets for help on using tickets.