Skip to content

PHP 8.2: Fix property typo in IXR_Message class#3777

Closed
anomiex wants to merge 4 commits intoWordPress:trunkfrom
anomiex:php-8.2/fix-property-typo-in-IXR
Closed

PHP 8.2: Fix property typo in IXR_Message class#3777
anomiex wants to merge 4 commits intoWordPress:trunkfrom
anomiex:php-8.2/fix-property-typo-in-IXR

Conversation

@anomiex
Copy link
Copy Markdown

@anomiex anomiex commented Dec 16, 2022

The IXR_Message class declares a property _currentTag, which is never assigned or used. It does assign to currentTag, which outside of that one assignment is never used either. A search on wpdirectory didn't turn up anything using either property (but lots of results for other classes having a property of the same name).

Since there are various other underscore-prefixed properties declared on the class, including one named _currentTagContents which is used in several places, it seems likely the declared property is correct and the assignment is a typo.

Trac ticket: https://core.trac.wordpress.org/ticket/56790


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

The IXR_Message class declares a property `_customTag`, which is never
assigned or used. It does assign to `customTag`, which outside of that
one assignment is never used either. A search on wpdirectory didn't turn
up anything using either property (but lots of results for other classes
having a property of the same name).

Since there are various other underscore-prefixed properties declared on
the class, including one named `_currentTagContents` which is used in
several places, it seems likely the declared property is correct and the
assignment is a typo.

Trac ticket: https://core.trac.wordpress.org/ticket/56033
Trac ticket: https://core.trac.wordpress.org/ticket/56009
Copy link
Copy Markdown

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @anomiex's conclusions here. Looking back, this typo came in with the original inclusion of xmlrpc via r1346 https://core.trac.wordpress.org/changeset/1346

I don't see either version of the property being used anywhere, so the change is functionally trivial.

Copy link
Copy Markdown
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I concur with the analysis and the change.

IIRC, this was originally an external library, which also explains the lack of tests. Would it be possible to add a perfunctory test to safeguard this change ?

I.e. a minimal test which triggers the tag_open() method and which would throw the "dynamic properties are deprecated" notice on PHP 8.2 without this change and no longer does so after this change.

@anomiex
Copy link
Copy Markdown
Author

anomiex commented Dec 17, 2022

Added a test, as requested.

Copy link
Copy Markdown
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test @anomiex !

✅ I've checked out the branch and I have confirmed that the test covers the originally identified issue. Without the change a "Creation of dynamic property IXR_Message::$currentTag is deprecated" notice is thrown and this is fixed with the change included.

I've left a suggestion for the test name and docblock. I'm not terribly sure about the current test class/file naming rules, @SergeyBiryukov should be able to provide guidance on that.

This patch can be committed under Trac ticket #56790.

Copy link
Copy Markdown
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anomiex Changes looks good to me.

@anomiex
Copy link
Copy Markdown
Author

anomiex commented Jan 19, 2023

So several people have approved this, what needs to be done for it to be committed?

@SergeyBiryukov
Copy link
Copy Markdown
Member

Thanks for the PR! Merged in r55105.

@anomiex anomiex deleted the php-8.2/fix-property-typo-in-IXR branch January 20, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants