[wp-trac] [WordPress Trac] #62035: SITE_ID_CURRENT_SITE broken in 6.3 or later

WordPress Trac noreply at wordpress.org
Mon Sep 16 09:47:20 UTC 2024


#62035: SITE_ID_CURRENT_SITE broken in 6.3 or later
-------------------------------------------------+-------------------------
 Reporter:  scottculverhouse                     |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.7
Component:  Networks and Sites                   |     Version:  6.3
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:  multisite
  testing                                        |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:13 scottculverhouse]:
 > I guess this issue is how PHP is tokenising the code and doesn't process
 `$this->$key = $value` the same as `$this->id = $value` therefore not
 passing to the `__set()`.

 Thanks for the ticket! Right, in my testing it also appears that `__get()`
 is only called when retrieving the property value outside of the class,
 but not within methods of the same class.

 For example,
 {{{
 class A {

         private $test = '1';

         public function __get( $key ) {
                 switch ( $key ) {
                         case 'test':
                                 return (int) $this->test;
                 }

                 return null;
         }

         public function get_test_value() {
                 return $this->test;
         }
 }

 $a = new A;
 var_dump( $a->test );
 var_dump( $a->get_test_value() );
 }}}
 outputs:
 {{{
 int(1)
 string(1) "1"
 }}}
 which explains the previous discrepancy here.

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


More information about the wp-trac mailing list