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

WordPress Trac noreply at wordpress.org
Thu Aug 19 02:10:21 UTC 2021


#53858: PHP 8.1: syntax error due to new 'readonly' property
-------------------------------------------------+-------------------------
 Reporter:  haosun                               |       Owner:  jrf
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  5.8.1
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  php81 needs-dev-note has-patch       |     Focuses:
  early has-unit-tests commit fixed-major        |
-------------------------------------------------+-------------------------

Comment (by jrf):

 @peterwilsoncc Thanks for pitching in. I agree that this backport is
 optional, at the same time, I kind of feel that a site potentially getting
 a white screen of dead due to a PHP parse error is kind of serious.

 Similar to the patch applied in this ticket for WP 5.9, plugins/themes
 cannot use the keyword `readonly` as a plain function call anymore when
 the plugin is used on PHP 8.1 as it would be a parse error.
 As most plugins and themes support more than just the latest and greatest
 of WP, any plugin using this function would need to jump through some
 hoops to make their code PHP and WP cross-version compatible.

 There are various solutions plugins/themes can use if we don't backport:
 * Stop using the WP Core function altogether and write their own logic to
 add the HTML attribute.
 * Conditionally, depending on the WP version, use
 `call_user_func('readonly', $args...)`.
 * Polyfill the function when it doesn't exist, but in a separate file,
 like in the patch here.

 This backport proposal means that plugins/themes can switch to using the
 new function name outright and that we greatly diminish the risk of
 burdening end-users with sites going down.

 If we don't backport, we really need to make it **''extremely clear''** in
 the dev-note how serious the problem is they will cause if plugins/themes
 do not adjust their code for this issue.

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


More information about the wp-trac mailing list