Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28582 closed defect (bug) (fixed)

Global declaration needed for variables in kses.php

Reported by: jaza613's profile Jaza613 Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: Formatting Keywords: has-patch
Focuses: Cc:


In 'wp-includes/kses.php', the three variables '$allowedposttags, $allowedtags, $allowedentitynames' are declared within an 'if' statement. Under normal circumstances, they end up in the global context as they should.

However, if the current PHP environment uses namespaces / autoload, they seem to not get added, resulting in this error:

Warning: in_array() expects parameter 2 to be array, null given in /path/to/wp-includes/kses.php line 1176

(Line 1176 is:)

return ( ( ! in_array($i, $allowedentitynames) ) ? "&$i;" : "&$i;" );

Attached patch fixes the issue, by declaring these variables with the 'global' keyword before assigning them a value.

Attachments (1)

kses_declare_globals.patch (547 bytes) - added by Jaza613 10 years ago.

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
10 years ago

  • Component changed from General to Formatting
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.0

#2 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28845:

In kses.php, ensure that $allowedposttags, $allowedtags, and $allowedentitynames are added to the global namespace.

Props Jaza613.
Fixes #28582.

Note: See TracTickets for help on using tickets.