I was trying to import a theme using Colibri Importer on version 6.0, but it kept getting stuck at 50%. When looking in the network tab, I saw that I was getting a 500
error back from the server, with a body of
<p>There has been a critical error on this website.</p><p><a href="https://wordpress.org/support/article/faq-troubleshooting/">Learn more about troubleshooting WordPress.</a></p>
How do I fix this error? See below :D
I looked into the server-side logs (I'm using a DigitalOcean WordPress droplet on Apache) in /var/log/apache2/error.log
and found further details on what was going wrong. In those logs, near the bottom was the following:
[Fri Jun 10 00:38:59.943725 2022] [php:error] [pid 195718] [client 73.188.75.186:58428] PHP Fatal error:
Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php:181
Stack trace:
#0 (181): trim()
#1 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php(275): Colibri\\Sync\\Endpoints\\Importer->getColibriUploadPath()
#2 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php(332): Colibri\\Sync\\Endpoints\\Importer->rename()
#3 [internal function]: Colibri\\Sync\\Endpoints\\Importer->execute_backup_content()
#4 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php(52): call_user_func()
#5 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Core/Endpoint.php(76): Colibri\\Sync\\Endpoints\\Importer->runStep()
#6 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/ColibriSync.php(186): Colibri\\Sync\\Core\\Endpoint->verifyAndExecute()
#7 /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/ColibriSync.php(151): Colibri\\Sync\\ColibriSync->import()
#8 /var/www/html/wp-includes/class-wp-hook.php(307): Colibri\\Sync\\ColibriSync->execute()
#9 /var/www/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#10 /var/www/html/wp-includes/plugin.php(476): WP_Hook->do_action()
#11 /var/www/html/wp-admin/admin-ajax.php(187): do_action()
#12 {main}\n thrown in /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php on line 181, referer: https://blog.tripbee.com/wp-admin/tools.php?page=colibri_sync_tools
I went to the mentioned file /var/www/html/wp-content/plugins/colibri-sync/src/Colibri/Sync/Endpoints/Importer.php
on my server, and looked at the function getColibriUploadPath
on line 181
, where the issue was stemming from. It appeared that the trim
function was expecting a string, but instead was being given an array. To fix it, I replaced
$rel = trim($rel);
with
if (is_array($rel)) {
$rel = trim(implode($rel));
}
elseif (is_string($rel)) {
$rel = trim($rel);
}
and saved the file. Without restarting the server or anything else, I reattempted the import and it succeeded! Hopefully this helps anyone who just updated to WP 6.0 and are struggling to get the Colibri Importer working on that version :)