Skip to content

phpcs hotfix#2921

Closed
sol-loup wants to merge 2 commits intomainfrom
phpcs-hotfix
Closed

phpcs hotfix#2921
sol-loup wants to merge 2 commits intomainfrom
phpcs-hotfix

Conversation

@sol-loup
Copy link
Copy Markdown
Contributor

@sol-loup sol-loup commented Mar 5, 2025

PR Summary

This PR reverts the addition of explicit property declarations in the AsyncRequest class.

We were seeing lint failures due to accessing an undefined property on the class.

The original code relied on property_exists() checks to determine if child classes had defined custom properties for query arguments, URL, and request arguments.

To fix the lint complaints, these variables were set to "null | undefined" on the class to indicate they were present but unused unless overridden dynamically.

However, explicitly declaring these properties in the parent class, broke this logic since property_exists() now always returns true for these properties, even when they're null.

This change restores the original dynamic property behavior, allowing child classes to optionally define these properties while maintaining the parent class's fallback logic.

Screenshots:

Detailed test instructions:

Additional details:

Changelog entry

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@sol-loup has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@sol-loup merged this pull request in cd07017.

facebook-github-bot pushed a commit that referenced this pull request Mar 7, 2025
Summary:
# Add Unit Tests for AsyncRequest Class
Adds comprehensive unit tests for the AsyncRequest utility class. The tests verify:
- Proper initialization of the class with correct action hooks
- Request data handling via set_data()
- Dispatch functionality with appropriate URL and arguments
- Nonce verification in the request handling flow

The implementation uses PHPUnit's mocking capabilities to intercept WordPress HTTP requests, as it's less straightforward / efficient to record and playback real network calls.

I've verified that the changes originally pushed in #2901  and reverted in #2921 cause these tests to fail.

Closes # .

_Replace this with a good description of your changes & reasoning._

- [ ] Do the changed files pass `phpcs` checks? Please remove `phpcs:ignore` comments in changed files and fix any issues, or delete if not practical.

### Screenshots:

### Detailed test instructions:

1.
2.
3.

### Additional details:

<!--
Optional.
Enter a summary of all changes in this Pull Request, which will be added to the changelog if accepted.
Each line should start with change type prefix`(Fix|Add|…) - `, for example:
> Break - A change breaking previous API or functionality.
> Add - A new feature, function or functionality was added.
> Update - Big changes to something that wasn't broken.
> Fix - Took care of something that wasn't working.
> Tweak - Small change, that isn't actually very important.
> Dev - Developer-facing only change.
> Doc - Updated customer or developer facing documentation

If you remove the "Changelog entry" header, the Pull Request title will be used as the changelog entry.

Add the `changelog: none` label if no changelog entry is needed.
-->
### Changelog entry

>

Pull Request resolved: #2922

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!**
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/17451448627576264
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/1125900312114451

Reviewed By: carterbuce, jczhuoMeta

Differential Revision: D70733339

Pulled By: sol-loup

fbshipit-source-id: 2fc7f837913cbe021ffa143021900076d80ee030
tzahgr pushed a commit that referenced this pull request Mar 25, 2025
Summary:
# PR Summary
This PR reverts the addition of explicit property declarations in the AsyncRequest class.

We were seeing lint failures due to accessing an undefined property on the class.

The original code relied on property_exists() checks to determine if child classes had defined custom properties for query arguments, URL, and request arguments.

To fix the lint complaints, these variables were set to "null | undefined" on the class to indicate they were present but unused unless overridden dynamically.

However, explicitly declaring these properties in the parent class, broke this logic since property_exists() now always returns true for these properties, even when they're null.

This change restores the original dynamic property behavior, allowing child classes to optionally define these properties while maintaining the parent class's fallback logic.

### Screenshots:

### Detailed test instructions:

1.
2.
3.

### Additional details:

<!--
Optional.
Enter a summary of all changes in this Pull Request, which will be added to the changelog if accepted.
Each line should start with change type prefix`(Fix|Add|…) - `, for example:
> Break - A change breaking previous API or functionality.
> Add - A new feature, function or functionality was added.
> Update - Big changes to something that wasn't broken.
> Fix - Took care of something that wasn't working.
> Tweak - Small change, that isn't actually very important.
> Dev - Developer-facing only change.
> Doc - Updated customer or developer facing documentation

If you remove the "Changelog entry" header, the Pull Request title will be used as the changelog entry.

Add the `changelog: none` label if no changelog entry is needed.
-->
### Changelog entry

>

Pull Request resolved: #2921

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!**
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/281475381994203
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/15762598767124196

Reviewed By: mradmeta

Differential Revision: D70652138

Pulled By: sol-loup

fbshipit-source-id: 396fadbca8106fbf88cfe1e2764f0cc05dfd7c49
tzahgr added a commit that referenced this pull request Mar 25, 2025
@tzahgr tzahgr mentioned this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants