Repository navigation
Commit d1b25df
committed
Code Quality: Resolve
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#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-d223f7449a82variable.undefined errors in wp-mail.php and wp-trackback.php.1 parent 774837f commit d1b25df
3 files changed
Lines changed: 10 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
94 | | - | |
| 94 | + | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | 911 | | |
917 | 912 | | |
918 | 913 | | |
| |||
923 | 918 | | |
924 | 919 | | |
925 | 920 | | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
0 commit comments