[wp-trac] [WordPress Trac] #53858: PHP 8.1: syntax error due to new 'readonly' property

WordPress Trac noreply at wordpress.org
Mon Aug 2 09:21:33 UTC 2021


#53858: PHP 8.1: syntax error due to new 'readonly' property
-------------------------------+-----------------------------
 Reporter:  haosun             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Future Release
Component:  General            |     Version:  4.9
 Severity:  normal             |  Resolution:
 Keywords:  php81 needs-patch  |     Focuses:
-------------------------------+-----------------------------

Comment (by haosun):

 Thanks for your replies. @swissspidy and @knutsp

 Here is some background. I'm working on developing PHP JIT 8.1, and I used
 ngix+mysql+wrk+wordpress to test the performance of PHP JIT. And this
 error is exposed just after new 'readonly' property is introduced.


 > Interestingly I couldn't find any use of this function in WordPress nor
 any WordPress plugin or theme (via https://wpdirectory.net/). Looks like
 it was just added out of convenience/consistency in #16886.
 >

 If so, I think my workaround would work, i.e. simply renaming `readonly()`
 to another name.
 However, based on my testing, this workaround would affect the
 performance.

 Note that I used the PHP 8.1 version just before 'readonly' property is
 introduced, and run the performance testing two times. In the first time,
 I didn't change wordpress, and in the second time, I renamed 'readonly'
 function to 'readonly_workaround' (in the same way as you said). But I
 found the performance data is downgraded from 174.51 requests/s to 154.31
 requests/s.

 That's why I suspected I might miss some use sites of function 'readonly'.
 But I'm not sure anyway.
 Do you have any hints for this performance regression? Thanks.

 ----

 > Renaming to `wp_readonly()` and making `readonly()` an alias of that on
 PHP < 8.1 sounds reasonable as long as it doesn't cause syntax errors
 anymore. It should be marked as deprecated though.

 May I ask one simple question? How can I define an **alias**? Could you
 show me one example? I'm not familiar with PHP actually. Thanks in
 advance.

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


More information about the wp-trac mailing list