menu

Questions & Answers

"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.

Comments:
2023-01-11 09:00:13
You may want to check if you have: wp-includes/formatting.php, which defines trailingslashit(), used by WP_Textdomain_Registry::set() (invoked in line 103). If needed, you can research the details at wp developer resources
2023-01-11 09:00:13
I checked and I found it
Answers(9) :

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;

Got the same error several times since 6.1.x, I think on some servers this is just a timeout problem.

Have to compare some different instalations on different hosts.

And check if there ist still the .maintenance in your WP dir.

Update: I found a possible incompatibility with a TikTok plugin, but I'm not sure. In fact, after some updates that worked fine, the problem returned.

Comments:
2023-01-11 09:00:13
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
2023-01-11 09:00:13
One of your plugins is incompletely tested with WordPress 6.1. Plugin authors should test plugin upgrades with each new core upgrade, because this kind of thing might happen. If you can figure out which plugin is at fault, you should pester the plugin author to fix the problem. (Look up WP_DEBUG_LOG for a way to catch errors in the upgrade process.) In the meantime, either delete the offending plugin or roll back to WordPress 6.0.x.

Update: I found a user that had a similar problem, he solved by deleting the wp_includes folder and then re-uploading it via FTP. I tried too: in staging environment it worked but in production the error still appears after updating any plugin :(

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.

Check you have installed php-psr. I had this error as I hadn't installed php8.1-psr

Comments:
2023-01-11 09:00:13
Thank you for the advice. Where can I check that?
2023-01-11 09:00:13
I suspect you'll have to speak to your hosting company. If you have shell / SSH access then you would run something like: sudo apt get install php-psr Note: this assumes you're running Ubuntu / Debian

Looks like the formatting.php functions are not available anymore when updating.

Comments:
2023-01-11 09:00:13
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

it is a bug in WP Core and will be fixed in 6.1.2

https://core.trac.wordpress.org/changeset/55010

Thanks Sean, saved my day! :-)

Comments:
2023-01-11 09:00:14
This does not provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractions