[wp-trac] [WordPress Trac] #59718: Short-term (WP 6.4) hotfix to prevent fatal error in standalone Gutenberg (<16.5)
WordPress Trac
noreply at wordpress.org
Wed Oct 25 16:12:33 UTC 2023
#59718: Short-term (WP 6.4) hotfix to prevent fatal error in standalone Gutenberg
(<16.5)
-----------------------------------------------+---------------------
Reporter: rebasaurus | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.4
Component: Upgrade/Install | Version:
Severity: critical | Resolution:
Keywords: reporter-feedback close has-patch | Focuses:
-----------------------------------------------+---------------------
Comment (by hellofromTonya):
Clarifying [comment:16 my comments]:
> Reverting [56575] will impact not only those past releases, but also
current and future development. Why? Reverting the method back to
`private` means the method cannot be overloaded or invoked within
Gutenberg.
Reverting [56575] will not cause a fatal error on the past releases or
currently in Gutenberg `trunk`.
Reverting this change needs broader consideration beyond this ticket as it
can have impacts such as creating risks and additional development effort
due to how PHP handles `private` access.
Let me explain:
Private methods are not overloadable and cannot be invoked outside of the
class. See it in action https://3v4l.org/J5u29.
As a private method can only be run from within the class that has the
method, care must be given to avoid fatal errors and invoking the wrong
method.
[https://www.php.net/manual/en/language.oop5.inheritance.php From the PHP
manual]:
>Private methods of a parent class are not accessible to a child class. As
a result, child classes may reimplement a private method themselves
without regard for normal inheritance rules.
A fatal error can happen if a child class invokes the private method, but
does not have a copy of that method within its class.
* The risk is minor in the wild as the visibility change has not shipped
yet.
* The risk can be managed in Gutenberg through testing and CI jobs.
Code may not behave as intended when invoking the parent's code that then
invokes the private method (see it in action https://3v4l.org/TtXpK).
* Extra burden: This means when extending a class, all of the code that
invokes a private method(s) must be copied into the extended class, even
if it's not customized.
Extra burden happens when merging code between Gutenberg and Core.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59718#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list