Repository navigation
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@robelsust Thanks for the PR! I already addressed that feedback in my PR, so please remove those changes from this PR. For the remaining baseline issues, please fix the |
27eb717 to
33dccdb
Compare
variable.undefined errors in root entry-point scriptsvariable.undefined errors in wp-mail.php and wp-trackback.php
…d `wp-trackback.php`. 1. **`src/wp-mail.php`**: Initialize `$subject = '';` alongside the other per-message variables (`$bodysignal`, `$boundary`, `$charset`, etc.) before the `foreach ( $message as $line )` loop. Without this, `$subject` is only assigned when a line matches `/Subject: /i`, so PHPStan correctly flags it as potentially undefined when the loop completes without a match. 2. **`src/wp-trackback.php`**: Add `global $wpdb, $posts;` with `@global` docblocks in file scope. `$wpdb` is used four times (two `prepare` calls, one `get_results`, one `insert_id`) and `$posts` once (`$posts[0]->ID`), all reachable after `require wp-load.php`. 3. **`tests/phpstan/baselines/variable.undefined.neon`**: Remove the three resolved suppression entries (6 errors total). Developed in #13880. Follow-up to r51850, r53719. Props therssoftware, mukesh27. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@64072 602fd350-edb4-49c9-b593-d223f7449a82
…d `wp-trackback.php`. 1. **`src/wp-mail.php`**: Initialize `$subject = '';` alongside the other per-message variables (`$bodysignal`, `$boundary`, `$charset`, etc.) before the `foreach ( $message as $line )` loop. Without this, `$subject` is only assigned when a line matches `/Subject: /i`, so PHPStan correctly flags it as potentially undefined when the loop completes without a match. 2. **`src/wp-trackback.php`**: Add `global $wpdb, $posts;` with `@global` docblocks in file scope. `$wpdb` is used four times (two `prepare` calls, one `get_results`, one `insert_id`) and `$posts` once (`$posts[0]->ID`), all reachable after `require wp-load.php`. 3. **`tests/phpstan/baselines/variable.undefined.neon`**: Remove the three resolved suppression entries (6 errors total). Developed in WordPress/wordpress-develop#13880. Follow-up to r51850, r53719. Props therssoftware, mukesh27. See #65817. Built from https://develop.svn.wordpress.org/trunk@64072 git-svn-id: http://core.svn.wordpress.org/trunk@63231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
Thanks for the PR! Merged in r64072. |
Trac ticket: https://core.trac.wordpress.org/ticket/65817
Follow-up to #13810 (review)
Resolves three
variable.undefinedbaseline entries covering six error occurrences inwp-mail.phpandwp-trackback.php. Thewp-activate.phpandwp-signup.phpchanges are handled separately in PR #13810.wp-mail.php$subjectforeachonly when aSubject:header matcheswp-trackback.php$wpdbwp-settings.phpvia$GLOBALS, used afterrequire wp-load.phpwp-trackback.php$postswp-settings.phpvia$GLOBALS, used afterrequire wp-load.phpChanges
src/wp-mail.php: Initialize$subject = '';alongside the other per-message variables ($bodysignal,$boundary,$charset, etc.) before theforeach ( $message as $line )loop. Without this,$subjectis only assigned when a line matches/Subject: /i, so PHPStan correctly flags it as potentially undefined when the loop completes without a match.src/wp-trackback.php: Addglobal $wpdb, $posts;with@globaldocblocks in file scope.$wpdbis used four times (twopreparecalls, oneget_results, oneinsert_id) and$postsonce ($posts[0]->ID), all reachable afterrequire wp-load.php.tests/phpstan/baselines/variable.undefined.neon: Remove the three resolved suppression entries (6 errors total).Background
The
$subjectvariable inwp-mail.phphas been conditionally assigned inside the header-parsing loop since the file's earliest form. The surrounding variables ($bodysignal,$boundary,$charset,$content,$content_type,$content_transfer_encoding,$post_author,$author_found,$post_date,$post_date_gmt) were all given explicit initializations in r42343 (2017-11-30, Gary Pendergast), but$subjectwas missed.The
$wpdband$postsusages inwp-trackback.phpdate to the earliest revisions of the file. Variable names were cleaned up in r53719 (2022-07-19, Sergey Biryukov), but noglobaldeclaration was added since the file operates at the global scope viarequire.Testing instructions
trunk,npm run typecheck:phpreports[OK] No errors, because all three occurrences are baselined.tests/phpstan/baselines/variable.undefined.neonwithout applying the source changes, then run again. PHPStan reports:Variable $subject might not be defined.insrc/wp-mail.phpVariable $wpdb might not be defined.(×4) insrc/wp-trackback.phpVariable $posts might not be defined.insrc/wp-trackback.phpnpm run typecheck:phpreports[OK] No errorswith all three baseline entries removed and no new errors elsewhere.composer lintis clean on both changed files.composer phpstan:baselines -- --identifier=variable.undefined, not edited by hand.Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity IDE
Model(s): Claude Opus 4
Used for: Locating the
variable.undefinedoccurrences via the PHPStan baseline,git blame/git log -Sarchaeology to trace each variable's origin, and drafting this description. The source changes, baseline regeneration, and verification against PHPStan and PHPCS were reviewed and confirmed by me in a local development environment.