[wp-trac] [WordPress Trac] #53858: PHP 8.1: syntax error due to new 'readonly' property
WordPress Trac
noreply at wordpress.org
Mon Aug 2 08:25:39 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: Awaiting Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by haosun):
Replying to [comment:1 knutsp]:
> Hello @haosun and welcome to Trac!
>
> Nice find. Nasty thing.
>
> Would this work?
>
> 1. Rename `readonly()` to `wp_readonly()`
> 2. If PHP<8.1 : `function readonly()` calls `wp_readonly()`
>
> This function has "friends", like `checked()`. Also alias them for some
consistency?
>
Hi @knutsp Thanks for your reply.
I'm afraid I didn't fully get your point.
As shown in the error msg, 'readonly' function is defined in wp-includes
/general-template.php on line 4823
{{{
function readonly( $readonly, $current = true, $echo = true ) {
return __checked_selected_helper( $readonly, $current, $echo,
'readonly' );
}
}}}
Function 'readonly' calls '__checked_selected_helper', instead of
'wp_readonly()'.
I suppose one straightforward fix is to rename function 'readonly' at
definition site and all the use sites. However, as I grepped by
"readonly(", I didn't find any call site of this function. I'm not sure if
I missed something.
My workaround:
I simply renamed 'function readonly(' to 'function readonly_workaround(',
and yes this syntax error is gone. But I suspect it's incomplete because I
guess there must exist use sites of function 'readonly' but I missed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53858#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list