Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#57218 closed defect (bug) (fixed)

undefined function trailingslashit() when .maintenance present - Windows server

Reported by: grl570810 Owned by: swissspidy
Priority: normal Milestone: 6.2
Component: I18N Version: 6.1
Severity: normal Keywords: has-patch fixed-major
Cc: Focuses:

Description

This is the first core bug I've ever reported so apologies if I don't quite follow correct protocol.

When 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…

HP 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}

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.

@harishanker on my original post in the support forum ​https://wordpress.org/support/topic/undefined-function-trailingslashit-when-maintenance-present/ suggests that the issue arises from changeset 54669 https://core.trac.wordpress.org/changeset/54669/

I'll be happy to test any fix on my server using an RC release.

Change History (17)

#1 @peterwilsoncc
4 years ago

  • Component General → I18N
  • Milestone Awaiting Review → 6.1.2

Hi @grl570810 and welcome to trac!

I see from the support ticket you were not experiencing this error in WordPress 6.0.x so I've moved this on to the 6.1.2 milestone for visibility.

This is the first core bug I've ever reported so apologies if I don't quite follow correct protocol.

It's great, thank you, providing the error trace is very helpful.

#2 @SergeyBiryukov
4 years ago

#57292 was marked as a duplicate.

#3 @SergeyBiryukov
4 years ago

#57359 was marked as a duplicate.

This ticket was mentioned in ​Slack in #core by skithund. ​View the logs.


4 years ago

#5 @bgoewert
4 years ago

#57444 was marked as a duplicate.

#6 @ocean90
4 years ago

#57335 was marked as a duplicate.

#7 @SergeyBiryukov
4 years ago

#57633 was marked as a duplicate.

#8 @SergeyBiryukov
4 years ago

#57633 was marked as a duplicate.

#9 @swissspidy
4 years ago

  • Keywords has-patch added

This ticket was mentioned in ​PR #3999 on ​WordPress/wordpress-develop by ​@swissspidy.


4 years ago
#10

WP_Textdomain_Registry: Use rtrim instead of untrailingslashit and trailingslashit directly.

Avoids formatting.php dependency and thus prevents errors when using wp_load_translations_early(), for example when in maintenance mode.

Trac ticket: https://core.trac.wordpress.org/ticket/57218

This ticket was mentioned in ​Slack in #core by costdev. ​View the logs.


4 years ago

​@swissspidy commented on ​PR #3999:


4 years ago
#12

Let's add a short comment to the file header why both functions cannot be used here. Similar to

​https://github.com/WordPress/wordpress-develop/blob/35a678b0e60837c85a16005ec27b1bc867f5dd53/src/wp-includes/functions.php#L2025

Fixed 👍

#13 @swissspidy
4 years ago

  • Owner set to swissspidy
  • Resolution → fixed
  • Status new → closed

In 55302:

I18N: Prevent fatal error in WP_Textdomain_Registry.

Use rtrim instead of untrailingslashit and trailingslashit directly.

Avoids formatting.php dependency and thus prevents an error when called via wp_load_translations_early(), which happens e.g. when in maintenance mode.

Props grl570810, ocean90.
Fixes #57218.

#14 @swissspidy
4 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closed → reopened

#16 @SergeyBiryukov
4 years ago

  • Milestone 6.1.2 → 6.2.1

Moving to 6.2.1, as there are no plans for 6.1.2 at this time.

#17 @SergeyBiryukov
4 years ago

  • Milestone 6.2.1 → 6.2
  • Resolution → fixed
  • Status reopened → closed

This is already included in the 6.2 branch as of [55504], no backport needed.

Note: See TracTickets for help on using tickets.