• Looking for some ideas here.
    Recently (I believe since the arrival of WP 6.1) if I am doing manual updates on any of the sites on my server, and place a .maintenance file in the site root, instead of getting the nice ‘under maintenance’ message they throw a 500 error like this…

    PHP Fatal error:  Uncaught Error: Call to undefined function trailingslashit() in D:\HTTP\WP_Sites\Recipes\wp-includes\class-wp-textdomain-registry.php:103
    Stack trace:
    #0 D:\HTTP\WP_Sites\Recipes\wp-includes\l10n.php(784): WP_Textdomain_Registry->set('default', 'en_AU', 'D:\\HTTP\\WP_Site...')
    #1 D:\HTTP\WP_Sites\Recipes\wp-includes\load.php(1401): load_textdomain('default', 'D:\\HTTP\\WP_Site...', 'en_AU')
    #2 D:\HTTP\WP_Sites\Recipes\wp-includes\load.php(278): wp_load_translations_early()
    #3 D:\HTTP\WP_Sites\Recipes\wp-settings.php(74): wp_maintenance()
    #4 D:\HTTP\WP_Sites\Recipes\wp-config.php(98): require_once('D:\\HTTP\\WP_Site...')
    #5 D:\HTTP\WP_Sites\Recipes\wp-load.php(50): require_once('D:\\HTTP\\WP_Site...')
    #6 D:\HTTP\WP_Sites\Recipes\wp-blog-header.php(13): require_once('D:\\HTTP\\WP_Site...')
    #7 D:\HTTP\WP_Sites\Recipes\index.php(17): require('D:\\HTTP\\WP_Site...')
    #8 {main}
      thrown in D:\HTTP\WP_Sites\Recipes\wp-includes\class-wp-textdomain-registry.php on line 103

    I don’t have any issues with the sites in normal running, only when I put into maintenance mode.

    NB my server is a Windows machine running PHP 7.4.19 and MySQL 5.7.21. I mention this as I believe it’s significant; the issue doesn’t occur if I put a .maintenance file onto one of the odd WP sites that I manage on a third party *nix server. My gut feel is that the way Windows uses \ in its path name rather than / in *nix is probably at the root of the issue.

    Relevant bits of wp-config:

    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
    	define( 'ABSPATH', __DIR__ . '/' );
    /** Sets up WordPress vars and included files. */
    require_once ABSPATH . 'wp-settings.php';
    /** Set the Temp Dir to a writable area within the site (defaults to c:\windows\tmp otherwise) */
    define('WP_TEMP_DIR', ABSPATH . 'wp-content/tmp');

    I will leave the site listed above in maintenance mode in case folks wish to view if for themselves (it’s a new site for a vanity project so no issue there).



    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Hari Shanker R


    Hi @grl570810

    That is definitely an odd problem! I did some digging, and found details of the changes that happened in WordPress 6.0.1 to: \wp-includes\class-wp-textdomain-registry.php: https://core.trac.wordpress.org/changeset/54669/

    To summarize, the update changes how WP_Textdomain_Registry stores the default languages path. This change addresses a past issue which caused a performance regression during just-in-time changes in locales. It fixes this by storing the default languages paths in a separate way, while at the same time making WP_Textdomain_Registry easier to maintain and adding new tests to catch future regressions. Looking at the changeset, I can see how this makes a reference to the trailingslashit() function and the untrailingslashit() function periodically, which adds and removes trailing slashes.

    From your error message, it appears that the maintenance mode is triggered from this line: #3 D:\HTTP\WP_Sites\Recipes\wp-settings.php(74): wp_maintenance(). However, it appears that while attempting to load the textdomain, one of the changes made in 6.0.1 (potentially the issue I reported above), seems to be causing troubles with the trailingslashit functions, causing this error.

    In other words, what I am suggesting is that this might be a core bug, especially since you observed that this is working fine with *nix servers. As you rightly identified, I suspect that it is the forward slashes that are causing the issue.

    I would suggest that you test with WordPress 6.0 if the issue repeats itself, and if it doesn’t, we can confirm that changeset #54669 is causing this regression. If that’s the case, would you be so kind as to report a core bug here? https://core.trac.wordpress.org/newticket
    More on that here: https://make.wordpress.org/core/handbook/testing/reporting-bugs/

    I know that wasn’t a solution, but I do hope that this guides you in the right direction!

    Thread Starter grl570810


    Hi @harishanker,

    Thanks so much for your informative response and for the work you have but in to investigate my issue. I will do as you suggest and test on a WP 6.0 site as soon as I get a bit of bandwidth (most likely this coming weekend); by the sound of things I believe you have probably pinpointed the source of the errant behaviour. If I can confirm that I will be very pleased to report it as a core bug (it will be quite exciting to do so, the first I have ever been involved in!).


    • This reply was modified 1 year, 7 months ago by grl570810.
    Thread Starter grl570810


    Hi @harishanker ,

    To update you; I’ve confirmed over the weekend that that issue doesn’t occur on a 6.0.x release site, so I believe you are correct in your diagnosis of the source of the problem. As you suggested I have logged a new ticket 57218 https://core.trac.wordpress.org/ticket/57218 as a core bug.


    Moderator Hari Shanker R


    Thanks for the update, @grl570810 and for doing those tests. Since the issue doesn’t occur in 6.0.x, this definitely looks like a bug to me.

    I just took a look at that Trac ticket, and I think you have done a fantastic job over there. Kudos on your first core ticket (and core contribution!). 🙂

    Btw, until the issue stands fixed, if you would like to enable maintenance mode on your site, may I suggest that you use a plugin to achieve this as a stopgap solution? https://wordpress.org/plugins/search/maintenance+mode/ Since maintenance mode plugins operate in a different way, I feel that using one of those plugins should help you in keeping your site on maintenance mode, and will help you achieve your requirement.

    I do hope that this helps you! I also hope that the bug gets fixed in the next release. All the very best!

    Very good catch. Thanks.

    fwiw I – suddenly (today not yesterday) – got the error locally on WAMP.
    Call to undefined function trailingslashit() in C:\wamp64\www\misite\wp-includes\class-wp-textdomain-registry.php on line 103

    After reading I commented out Line 74 and was up & running in – less than 60 seconds!!


    • This reply was modified 1 year, 7 months ago by Brian North.

    I have the same error but only during the updates of almost any plugin. Maybe it is because the maintenance mode is activated during the process. But I don’t know what to do exactly to fix that.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘undefined function trailingslashit() when .maintenance present’ is closed to new replies.