[wp-trac] [WordPress Trac] #56271: Site template issue in PHP 5.6
WordPress Trac
noreply at wordpress.org
Fri Jul 22 14:31:40 UTC 2022
#56271: Site template issue in PHP 5.6
---------------------------+------------------------------------------
Reporter: jonmackintosh | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 6.0
Severity: major | Resolution:
Keywords: | Focuses: administration, performance
---------------------------+------------------------------------------
Comment (by uofaberdeendarren):
The issue comes from this line here:
https://github.com/WordPress/WordPress/blob/master/wp-includes/block-
template-utils.php#L699
`$query_result` is an array of `WP_Block_Template` objects. The
`array_columns` tries to "pluck" out the IDs for each of the template
parts, to compare the current file-based template id to the database ones
to see if the template already exists.
There is a difference in how `array_columns` works between PHP 5 and PHP
7. PHP 7 works fine when using objects, but PHP 5 does not. See:
https://stackoverflow.com/a/23335938
That's why it works fine in PHP 7 because the return from `array_columns`
does correctly contain the IDs of the templates, which will then stop the
duplication. In PHP 5, the return is always an empty array, so the
following conditionals don't think there are any database template parts,
and therefore can duplicate them.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56271#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list