[wp-trac] [WordPress Trac] #42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284

WordPress Trac noreply at wordpress.org
Mon Mar 26 20:44:32 UTC 2018


#42814: PHP 7.2 Warning: ...wp-includes/post-template.php on line 284
-------------------------------+-----------------------
 Reporter:  internetwerk       |       Owner:
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:  4.9.6
Component:  Posts, Post Types  |     Version:  4.5
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:
-------------------------------+-----------------------

Comment (by gsarig):

 On my case, it happens on a different scenario: on a WooCommerce eshop I
 created a price filter. The filter works fine with no errors or warnings.
 If I select a price range that has no results, though, I get the warning,
 even if everything else seems OK and the actual content shows the "No
 products were found matching your selection." message, as it should.
 Adding


 {{{
 if ( ! is_array($pages) ) {
         $pages = [];
 }
 }}}


 doesn't help on my case, because then I get another Notice: Undefined
 offset: -1 ...on line 289, which is


 {{{
 $content = $pages[$page - 1];
 }}}

 What seems  to solve it for me is simply changing the line


 {{{
 if ( $page > count( $pages ) )
 }}}


 to that:


 {{{
 if ( $pages && $page > count( $pages ) )
 }}}

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


More information about the wp-trac mailing list