Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Call to undefined function trailingslashit()" wordpress PHP fatal error when trying to update plugins

We have a wordpress installation on provider wpengine. When we try to update some plugins we get the fatal PHP error in subject. The provider support do not know how to help us. This is the call stack of the error:

"PHP Fatal error: Uncaught Error: Call to undefined function trailingslashit() in /nas/content/live/sillaindustrie/wp-includes/class-wp-textdomain-registry.php:103\nStack trace:\n#0 /nas/content/live/sillaindustrie/wp-includes/l10n.php(784): WP_Textdomain_Registry->set('default', 'it_IT', '/nas/content/li...')\n#1 /nas/content/live/sillaindustrie/wp-includes/load.php(1401): load_textdomain('default', '/nas/content/li...', 'it_IT')\n#2 /nas/content/live/sillaindustrie/wp-includes/load.php(278): wp_load_translations_early()\n#3 /nas/content/live/sillaindustrie/wp-settings.php(74): wp_maintenance()\n#4 /nas/content/live/sillaindustrie/wp-config.php(67): require_once('/nas/content/li...')\n#5 /nas/content/live/sillaindustrie/wp-load.php(50): require_once('/nas/content/li...')\n#6 /nas/content/live/sillaindustrie/wp-blog-header.php(13): require_once('/nas/content/li...')\n#7 /nas/content/live/sillaindustrie/index.php(17): require('/nas/content/li...')\n#8 {main}\n thrown in /nas/content/live/sillaindustrie/wp-includes/class-wp-textdomain-registry.php on line 103, referer: https://silla.industries/wp-admin/update-core.php?action=do-plugin-upgrade"

It seems to be related to WPML plugin or similar, any suggest? Thanks G.

I tried to update wordpress plugin, but I cannot understand the source of the error. Maybe it is plugins incompatibility but I don't know how to discover it.

like image 913
gi.ottobit Avatar asked Dec 01 '25 20:12

gi.ottobit


2 Answers

As others have pointed out, this is an issue where wp-includes/formatting.php isn't available when the code in wp-includes/class-wp-textdomain-registry.php runs. It is an issue introduced by WordPress 6.1.

To work around this issue, you can change line 103 in wp-includes/class-wp-textdomain-registry.php from:

$this->all[ $domain ][ $locale ] = $path ? trailingslashit( $path ) : false;

To:

$this->all[ $domain ][ $locale ] = $path ? rtrim( $path, '/\\' ). '/' : false;
like image 112
Sean Avatar answered Dec 03 '25 12:12

Sean


Update: I find the cause of the problem. WordPress 6.1 have made important updates to the WP_Textdomain_Registry object. This causes the error when the maintenance mode is activated during the plugin update process.

like image 33
gi.ottobit Avatar answered Dec 03 '25 12:12

gi.ottobit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!