[wp-trac] [WordPress Trac] #42761: Undefined offset: -1 in wp-includes/post-template.php

WordPress Trac noreply at wordpress.org
Tue Apr 20 12:58:36 UTC 2021


#42761: Undefined offset: -1 in wp-includes/post-template.php
-------------------------------+-------------------------
 Reporter:  twisted1919        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  4.9.1
 Severity:  normal             |  Resolution:  worksforme
 Keywords:  reporter-feedback  |     Focuses:  template
-------------------------------+-------------------------
Changes (by hellofromTonya):

 * status:  new => closed
 * resolution:   => worksforme
 * milestone:  Awaiting Review =>


Comment:

 Hello @twisted1919,

 Thank you for your report.

 It sounds like a plugin changed the value of the global `$pages` variable.
 As it is a global variable, any code can change its value. It's designed
 to give access to themes, plugins, etc. With that access comes the
 potential for the value to be changed in unexpected ways, such as setting
 it to an empty array.

 I'm closing this ticket as it does not appear to be a bug in WordPress
 Core itself.

 I can understand the thinking of having core guard the value to prevent
 other code from resetting it to an empty array. However, the pages value
 is exposed by design. Changing it could cause problems for themes and
 plugins that use it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42761#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list