WordPress Version Migration
Backend fatal error php fatal error cannot declare class wp metadata lazyloader because the name is already in use in
Many individuals have encountered the following issue while migrating their WordPress version from 6.2.2 to 6.3. In the log files, they’ve come across the following error message:
“PHP Fatal error: Cannot declare class WP_Metadata_Lazyloader, because the name is already in use in /home/xxxx/public_html/wp-includes/class-wp-metadata-lazyloader.php on line 32”
This error appears to stem from a clash in class naming, as indicated by the message, leading to conflicts in the code. This scenario often arises when upgrading WordPress versions, particularly from 6.2.2 to 6.3.
WordPress core team is trying to determine the cause of the issue, you can track that on this ticket: https://core.trac.wordpress.org/ticket/59057
Workaround Solution
- Examine line number 191 in the wp-settings.php file. Ensure that there is no occurrence of the “class-wp-metadata-lazyloader.php” entry within this file. If you do find this entry, it indicates an improper installation of WordPress version 6.3.
- If you possess access to the admin panel, consider reinstalling version 6.3. In the event of limited access, acquire the WordPress core files from the following location: https://wordpress.org/download/
- Initiate FTP or use the file manager provided by your hosting service to create a backup of your files.
- Proceed to manually replace the wp-settings.php file in the root folder.
- This action should restore the functionality of your website and grant you access to the admin panel.
- To confirm the restoration’s success, it’s advisable to reinstall version 6.3.
- To achieve this, grant write permissions to the wp-admin folder. Then, from the backend, update to version 6.3.
- Once the installation of the new version is complete, verify the functionality of your site. It should be operational.
- Revert the permissions of the wp-admin folder to read-only.
- Your website should now be functioning seamlessly.
- If you encounter the scenario outlined in step #1, where the “class-wp-metadata-lazyloader.php” entry is absent in wp-settings.php, you can address this issue using the patch provided here: https://github.com/WordPress/wordpress-develop/pull/4992/files. Integrate this patch into your codebase.
- If any problems persist, kindly inform us, and we’ll be glad to assist further.