Skip to content

Prevent method names from being emitted as global WP functions in since-data generation#1276

Merged
davidperezgar merged 4 commits intotrunkfrom
copilot/fix-false-positive-php-function-detection
Apr 26, 2026
Merged

Prevent method names from being emitted as global WP functions in since-data generation#1276
davidperezgar merged 4 commits intotrunkfrom
copilot/fix-false-positive-php-function-detection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

wp_functions_compatibility was flagging PHP serialize() as a WordPress function introduced in 6.7 because the generated wp-functions-since.json incorrectly included a class method (WP_HTML_Processor::serialize) as a global function. This change tightens dataset generation so only true global functions are emitted.

  • Generator parsing fix

    • Updated tools/generate-wp-function-since-data.php brace/class-scope tracking to correctly stay inside class context even when token streams include curly-interpolation tokens.
    • Ensures class/trait/interface methods are excluded from function_since.
  • Dataset correction

    • Ran the updated generator script and committed the newly generated includes/Vars/wp-functions-since.json.
    • This removes the incorrect "serialize": "6.7.0" entry and refreshes the full dataset based on the fixed generation logic (including metadata/version updates from the regenerated source).
  • Regression coverage

    • Added a focused fixture plugin using PHP serialize() and a PHPUnit assertion in WP_Functions_Compatibility_Check_Tests confirming no wp_function_not_compatible_with_requires_wp error is reported for that usage.
$wpdb->update(
    $wpdb->options,
    [ 'option_value' => serialize( $items ) ],
    [ 'option_name' => 'cron' ]
);

> [!WARNING]
>
>

Copilot AI linked an issue Apr 23, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 23, 2026 11:47
Copilot AI changed the title [WIP] Fix false positive in detecting PHP function serialize Prevent method names from being emitted as global WP functions in since-data generation Apr 23, 2026
Copilot AI requested a review from ernilambar April 23, 2026 11:51
@ernilambar
Copy link
Copy Markdown
Member

@copilot run the modified generator script for new json and include it in the same pull request.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

@copilot run the modified generator script for new json and include it in the same pull request.

Done in commit 039abdd. I ran the updated generator and committed the regenerated includes/Vars/wp-functions-since.json to this PR.

@ernilambar ernilambar marked this pull request as ready for review April 23, 2026 12:08
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Copilot.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: Copilot.

Co-authored-by: ernilambar <nilambar@git.wordpress.org>
Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: frantorres <frantorres@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@davidperezgar davidperezgar merged commit d573e11 into trunk Apr 26, 2026
29 checks passed
@davidperezgar davidperezgar deleted the copilot/fix-false-positive-php-function-detection branch April 26, 2026 15:41
@davidperezgar davidperezgar added this to the 2.0.0 milestone May 2, 2026
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.

False positive in detecting PHP function

4 participants