Title: PHP:WARN in Canonical.php
Last modified: June 12, 2024

---

# PHP:WARN in Canonical.php

 *  Resolved [affinityinspiration](https://wordpress.org/support/users/affinityinspiration/)
 * (@affinityinspiration)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/phpwarn-in-canonical-php/)
 * I’m consistently getting this in my logs.
 * PHP Warning:  Undefined array key “host” in /Users/robert/www/Chalmers/wp-includes/
   canonical.php on line 716,727,and 730 and 751. Probably others. Also from time
   to time “scheme”
 * Which is all the places the warning appears. Now I know that this has been around
   for ages so I’m wondering when it is going to be solved. It’s nothing to do with
   a plugin, but I think more to do with redirection. Which is usually handled by.
   htaccess to start with. However…
 * Undefined array key usually means just that. The ‘key’ isn’t being defined for
   some reason.
 * Anybody got any current ideas on what’s going on here?
 * Thanks
    -  This topic was modified 2 years, 1 month ago by [affinityinspiration](https://wordpress.org/support/users/affinityinspiration/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [royjemee](https://wordpress.org/support/users/royjemee/)
 * (@royjemee)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/phpwarn-in-canonical-php/#post-17819202)
 * The PHP warning “Undefined array key” typically indicates that your code is attempting
   to access an index in an array that does not exist. In the context of WordPress,
   this could happen for a variety of reasons, such as a misconfiguration in the`.
   htaccess` file, issues with redirections, or problems with the WordPress core
   files or plugins.
 * Here are some steps to troubleshoot and resolve the issue:
 * **Check the `.htaccess` File:** 
   Ensure that the `.htaccess` file is correctly
   configured. Incorrect rewrite rules or missing directives can cause redirection
   issues that lead to undefined array keys. You can use the basic .htaccess file
   and try – [https://developer.wordpress.org/advanced-administration/server/web-server/httpd/](https://developer.wordpress.org/advanced-administration/server/web-server/httpd/)
 * **WordPress Core Files:**
   Also, it’s possible that something went wrong during
   an update or that files have been corrupted. To address this –
    - Go to the WordPress Dashboard -> Updates and click on “Re-Install Now” to 
      ensure you have the latest version of WordPress¹.
    - If the issue persists, manually download the latest WordPress package and 
      replace the `wp-includes` and `wp-admin` directories via FTP.
 * **Theme and Plugins:**
    - Temporarily switch to the default WordPress theme to rule out any theme-related
      issues.
    - Deactivate all plugins and reactivate them one by one to identify if a specific
      plugin is causing the issue¹.
 * **PHP Version:**
   The warning may also be related to the PHP version you are using.
   If you recently upgraded to PHP 8.x, some older code might not be fully compatible.
   Switch to a different PHP version for testing.
 * These all debugging ideas came to my mind now. Wish you good luck with testing.
 *  Thread Starter [affinityinspiration](https://wordpress.org/support/users/affinityinspiration/)
 * (@affinityinspiration)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/phpwarn-in-canonical-php/#post-17819403)
 * Thanks,
 * But none of these options fixed the issue. I’m running
 * Current version: 6.5.4
   Last checked on June 12, 2024 at 9:58 am GMT+0000.
 * The .htaccess file is good. All pages work fine. In fact everything works fine.
   Except I’m seeing the PHP Warn notices in the error_log
 * Can’t find anything wrong?
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/phpwarn-in-canonical-php/#post-17821180)
 * This is a known bug that apparently only occurs in a few constellations. See:
   [https://core.trac.wordpress.org/ticket/34353](https://core.trac.wordpress.org/ticket/34353)–
   I would recommend that you join the ticket and describe your environment as precisely
   as possible so that it can be recreated and solved.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP:WARN in Canonical.php’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [threadi](https://wordpress.org/support/users/threadi/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/phpwarn-in-canonical-php/#post-17821180)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
