-
Notifications
You must be signed in to change notification settings - Fork 7
Troubleshooting WordPress on bare metal
Note: We do not actually use this, but it was a fun learning experience for Anthony. See the new Troubleshooting and HOWTOs page for working with our Docker WordPress image.
Tested on Debian GNU/Linux bookworm/sid in February 2022
Fatal error: Uncaught mysqli_sql_exception: No such file or directory in /srv/riskprofiler.ca/site/wp-includes/wp-db.php:1653 (Click to expand)
Fatal error: Uncaught mysqli_sql_exception: No such file or directory in /srv/riskprofiler.ca/site/wp-includes/wp-db.php:1653 Stack trace: #0 /srv/riskprofiler.ca/site/wp-includes/wp-db.php(1653): mysqli_real_connect() #1 /srv/riskprofiler.ca/site/wp-includes/wp-db.php(632): wpdb->db_connect() #2 /srv/riskprofiler.ca/site/wp-includes/load.php(558): wpdb->__construct() #3 /srv/riskprofiler.ca/site/wp-settings.php(124): require_wp_db() #4 /srv/riskprofiler.ca/site/wp-config.php(107): require_once('...') #5 /srv/riskprofiler.ca/site/wp-load.php(50): require_once('...') #6 /srv/riskprofiler.ca/site/wp-blog-header.php(13): require_once('...') #7 /srv/riskprofiler.ca/index.php(17): require('...') #8 {main} thrown in /srv/riskprofiler.ca/site/wp-includes/wp-db.php on line 1653
Solution: Set up MySQL or MariaDB properly.
PHP 8.1, which is what is in Debian sid as of February 2022, is too new for WordPress 5.8.x, and gives lots of deprecation notices on the rendered page:
Deprecation notices (Click to expand)
Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-theme.php on line 554
Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-theme.php on line 595
Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-theme.php on line 535
Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-theme.php on line 544
Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/rest-api/class-wp-rest-request.php on line 960
Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/rest-api/class-wp-rest-request.php on line 980
Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/rest-api/class-wp-rest-request.php on line 992
Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/rest-api/class-wp-rest-request.php on line 1003
Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 151
Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 175
Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 164
Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 186
Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 138
Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 75
Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 89
Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 110
Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 127
Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/riskprofiler.ca/site/wp-includes/class-wp-block-list.php on line 199
Warning: session_start(): Session cannot be started after headers have already been sent in /srv/riskprofiler.ca/site/assets/themes/fw-parent/functions.php on line 165
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /srv/riskprofiler.ca/site/wp-includes/class-wp.php on line 173
Add the following lines to /etc/apt/preferences:
Package: src:php-defaults
Pin: version 2:76
Pin-Priority: 1001
which allows us to downgrade php-common from 2:92 (requiring PHP 8.1) to 2:76 (requiring PHP 7.4), which allows us to downgrade from libapache2-mod-php8.1 to libapache2-mod-php7.4 accordingly.
Prepend
error_reporting(E_ALL ^ E_DEPRECATED);
to site/wp-includes/class-wp-theme.php
Credit: wordpress - Turn off deprecated errors in PHP 5.3 - Stack Overflow
Add #[\ReturnTypeWillChange]
attribute to the relevant class methods; see https://php.watch/versions/8.1/ReturnTypeWillChange
Symptom: The web page is rendered (actual HTML code returned), with <title>
and all, but no actual content.
Cause (in our case): Missing theme files: site/assets/themes/fw-parent is a git submodule which wasn't loaded.
Solution: Make sure .gitmodules exists and points to the correct repo, and run git submodule update --init
What about built-in themes?
- twentytwentytwo theme requires WordPress 5.9+ and is incompatible with WordPress 5.8.x that RiskProfiler.ca is currently using
- twentytwentyone theme: cannot see the menu that leads to Scenarios, Risks etc.
- twentytwenty theme works! The top menu actually show!
Not Found (404) error when accessing http://riskprofiler.demo/scenarios/
(but top-level http://riskprofiler.demo/ directory works)
- Make sure Apache allows
.htaccess
...AllowOverride All
, and that the rewrite module is on:sudo a2enmod rewrite
Wikis: data | model-factory | opendrr-api | opendrr | python-env | riskprofiler-cms