Skip to content

500 on wp-admin/theme-editor.php — $allowed_files not registered as a global #44

Description

@Spomky

Description

Loading wp-admin/theme-editor.php through the bundle results in an HTTP 500:

Warning: Trying to access array offset on null
at wp-admin/includes/file.php line 84

Root cause

WordpressLoader::createWordpressResponse() requires the WordPress entry point inside a method scope, and only the variables listed in WordpressGlobals::GLOBALS are promoted to real globals via the global $$global; loop.

theme-editor.php builds $allowed_files at script level, expecting it to be a true global. Later, wp_print_theme_file_tree()get_file_description() does global $allowed_files; and reads it. Since allowed_files is missing from WordpressGlobals::GLOBALS, the array built by theme-editor.php stays local to the method, so get_file_description() reads null$allowed_files[$file] → warning → 500.

Note: wp_file_descriptions (the sibling global used in the very same function) is already in the list — allowed_files was simply omitted.

Fix

Add 'allowed_files' to WordpressGlobals::GLOBALS (alphabetically, between all_links and allowedentitynames). A PR follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions