Skip to content

Register $allowed_files as a WordPress global (fix 500 on theme-editor.php)#45

Open
Spomky wants to merge 1 commit into
phpsword:masterfrom
Spomky:fix/allowed-files-global
Open

Register $allowed_files as a WordPress global (fix 500 on theme-editor.php)#45
Spomky wants to merge 1 commit into
phpsword:masterfrom
Spomky:fix/allowed-files-global

Conversation

@Spomky

@Spomky Spomky commented Jun 28, 2026

Copy link
Copy Markdown

Problem

Opening wp-admin/theme-editor.php returns an HTTP 500:

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

Cause

WordpressLoader::createWordpressResponse() requires the WordPress entry point inside a method, so only the names listed in WordpressGlobals::GLOBALS are promoted to real globals.

theme-editor.php builds $allowed_files at script scope and expects it to be a true global; get_file_description() later reads it via global $allowed_files;. As allowed_files was missing from the list, the array stayed local to the method and the function read null.

The sibling global wp_file_descriptions, used in the same function, was already present — allowed_files was just omitted.

Change

Adds 'allowed_files' to WordpressGlobals::GLOBALS (kept in alphabetical order).

Closes #44

wp-admin/theme-editor.php builds $allowed_files at script scope and relies
on it being a true global. Because WordpressLoader requires the WP entry
point inside a method, only the names listed in WordpressGlobals::GLOBALS
become real globals. allowed_files was missing, so get_file_description()
read null and triggered a 500 (Trying to access array offset on null).

Fixes phpsword#44
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.

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

1 participant