PHP Warning: Undefined array key “HTTP_HOST” in v11.75 – Still Persistent
-
<span style=”font-size: inherit; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;”>Hello WPMobile.App Support Team,</span>
I am writing to you regarding a persistent PHP Warning that is appearing in my website’s
error_logfile. The warning originates from your plugin, even though I am running the latest version (v11.75).<b>Error Details:</b>
<b>Plugin Version:</b> 11.75
<b>Full Warning Text:</b>
<response-element class=”” ng-version=”0.0.0-PLACEHOLDER”><code-block _nghost-ng-c3693737113=”” class=”ng-tns-c3693737113-95 ng-star-inserted”></code-block></response-element><code _ngcontent-ng-c3693737113="" role="text" data-test-id="code-content" class="code-container formatted ng-tns-c3693737113-95 no-decoration-radius">PHP Warning: Undefined array key "HTTP_HOST" in /wp-content/plugins/wpappninja/inc/functions/seo.php on line 20
<b>Current Code on Line 20:</b>
<response-element class=”” ng-version=”0.0.0-PLACEHOLDER”><code-block _nghost-ng-c3693737113=”” class=”ng-tns-c3693737113-96 ng-star-inserted”></code-block></response-element><span _ngcontent-ng-c3693737113=”” class=”ng-tns-c3693737113-96″>PHP</span><code _ngcontent-ng-c3693737113="" role="text" data-test-id="code-content" class="code-container formatted ng-tns-c3693737113-96"><span class="hljs-variable">$url</span> = <span class="hljs-variable">$_SERVER</span>[<span class="hljs-string">'HTTP_HOST'</span>] . <span class="hljs-variable">$_SERVER</span>[<span class="hljs-string">'REQUEST_URI'</span>];
<b>Issue:</b> This warning appears when the code is executed via background processes (like WP-Cron), where the
HTTP_HOSTvalue is not defined in the$_SERVERarray.
<b>Suggested Solution (to assist with the fix):</b>
The warning can be avoided by checking for the key’s existence using the Null Coalescing Operator (
<response-element class=”” ng-version=”0.0.0-PLACEHOLDER”><code-block _nghost-ng-c3693737113=”” class=”ng-tns-c3693737113-97 ng-star-inserted”>??):</code-block></response-element><span _ngcontent-ng-c3693737113=”” class=”ng-tns-c3693737113-97″>PHP</span><code _ngcontent-ng-c3693737113="" role="text" data-test-id="code-content" class="code-container formatted ng-tns-c3693737113-97"><span class="hljs-variable">$url</span> = (<span class="hljs-variable">$_SERVER</span>[<span class="hljs-string">'HTTP_HOST'</span>] ?? <span class="hljs-string">''</span>) . <span class="hljs-variable">$_SERVER</span>[<span class="hljs-string">'REQUEST_URI'</span>];
We kindly request that you include this modification in the next plugin update.
Thank you for your time and efforts.
Sincerely,
The topic ‘PHP Warning: Undefined array key “HTTP_HOST” in v11.75 – Still Persistent’ is closed to new replies.