WPIntell

Source evidence

Errors when used with WP-CLI

Related Posts for WordPress · support · 2024-03-06T09:16:00+00:00

mixedsentiment
mediumseverity
0.84relevance
3replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 20 rows with source links

20.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

16 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Matt Lowe resolved
Hey. There’s a small error in this plugin which triggers when using WP-CLI. PHP Warning: Undefined array key "HTTP_HOST" in /var/www/vhosts/example.com/htdocs/wp-content/plugins/related-posts-for-wp/classes/class-playground.php on line 9 Warning: Undefined array key "HTTP_HOST" in /var/www/vhosts/example.com/htdocs/wp-content/plugins/related-posts-for-wp/classes/class-playground.php on line 9 The error appears to be harmless, but it emits the error twice for every execution of WP-CLI, which is polluting the logs of our automated processes. On one website with Related Posts for WP installed that error message appears in the logs over 50 times every day when a number of automated tasks are executed. All it needs is to change: if ( strpos( $_SERVER['HTTP_HOST'], "playground.wordpress.net" ) !== false ) { To: if ( strpos( $_SERVER['HTTP_HOST'] ?? '', "playground.wordpress.net" ) !== false ) { Actually, I’ve just noticed you support PHP5.3 upwards, so the null coalescing operator can’t be used. Somethng like this ought to do it: if ( strpos( isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '', "playground.wordpress.net" ) !== false ) { This reply was modified 2 years, 2 months ago by Matt Lowe . Thanks for reporting, this was fixed in 2.2.2 Just upgraded to 2.2.2 and, sure enough, no more errors. Thanks for the swift fix!

Comments

3 shown
Matt Lowe 2024-03-06T09:20:00+00:00

Actually, I’ve just noticed you support PHP5.3 upwards, so the null coalescing operator can’t be used. Somethng like this ought to do it: if ( strpos( isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '', "playground.wordpress.net" ) !== false ) { This reply was modified 2 years, 2 months ago by Matt Lowe .

Barry Kooij 2024-03-12T11:40:00+00:00

Thanks for reporting, this was fixed in 2.2.2

Matt Lowe 2024-03-12T12:12:00+00:00

Just upgraded to 2.2.2 and, sure enough, no more errors. Thanks for the swift fix!