[wp-trac] [WordPress Trac] #35013: WP4.4 function handle_404 yelds a fatal error on line 613 when trying to clone $wp_query->post if it's not an object

WordPress Trac noreply at wordpress.org
Thu Dec 17 07:37:49 UTC 2015


#35013: WP4.4 function handle_404 yelds a fatal error on line 613 when trying to
clone $wp_query->post if it's not an object
------------------------------+-------------------------
 Reporter:  jdmweb            |       Owner:  swissspidy
     Type:  defect (bug)      |      Status:  assigned
 Priority:  normal            |   Milestone:  4.4.1
Component:  Bootstrap/Load    |     Version:  4.4
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+-------------------------
Changes (by swissspidy):

 * owner:   => swissspidy
 * status:  new => assigned


Comment:

 Replying to [comment:7 igmoweb]:
 > Replying to [comment:6 swissspidy]:
 > Thanks @swissspidy. I still don't use curly braces on ifs with single
 lines due to old PHP Coding Standards. Do we need to add them in the
 patch?

 We use them everywhere for new code that we introduce, as per the
 [https://make.wordpress.org/core/handbook/best-practices/coding-
 standards/php/ WordPress PHP Coding Standards].

 Since this is a rather small change, we can manually add them when
 committing. I'd probably do it like this:

 {{{#!php

 if ($wp_query->post instanceof WP_Post ) ) {
         $p = clone $wp_query->post;
 }
 }}}

 The reason for this is that `is_a` is deprecated before PHP 5.3.0 and
 throws `E_STRICT` warnings. See:
 http://php.net/manual/en/function.is-a.php#refsect1-function.is-a-changelog

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


More information about the wp-trac mailing list