WordPress.org

Make WordPress Core

Opened 14 months ago

Closed 10 months ago

Last modified 9 months ago

#23555 closed defect (bug) (fixed)

Fatal error when sunrise added

Reported by: Rahe Owned by: nacin
Milestone: 3.5.2 Priority: low
Severity: normal Version: 3.5.1
Component: Multisite Keywords: has-patch
Focuses: Cc:

Description

Hi,

I have installed a WordPress multisite subdomains on a server. I have added a sunrise.php file on the wp-content folder.

In this file there is a $wpdb->prepare without the needed argument at the end. WordPress throw a _doing_it_wrong() but this launch a Fatal error :

Fatal error: Call to undefined function __() in /home/site/public_html/wp-includes/functions.php
Call Stack:
    0.0001     335660   1. {main}() /home/site/public_html/wp-admin/network/settings.php:0
    0.0001     335964   2. require_once('/home/site/public_html/wp-admin/network/admin.php') /home/site/public_html/wp-admin/network/settings.php:11
    0.0001     336260   3. require_once('/home/site/public_html/wp-admin/admin.php') /home/site/public_html/wp-admin/network/admin.php:13
    0.0002     336564   4. require_once('/home/site/public_html/wp-load.php') /home/site/public_html/wp-admin/admin.php:30
    0.0002     337136   5. require_once('/home/site/public_html/wp-config.php') /home/site/public_html/wp-load.php:29
    0.0002     337500   6. require('/home/site/public_html/wp-config-dev.php') /home/site/public_html/wp-config.php:6
    0.0003     339004   7. require_once('/home/site/public_html/wp-settings.php') /home/site/public_html/wp-config-dev.php:109
    0.0037     791980   8. require('/home/site/public_html/wp-includes/ms-settings.php') /home/site/public_html/wp-settings.php:87
    0.0038     793784   9. include_once('/home/site/public_html/wp-content/sunrise.php') /home/site/public_html/wp-includes/ms-settings.php:18
    0.0039     795552  10. wpdb->prepare() /home/site/public_html/wp-content/sunrise.php:41
    0.0039     795872  11. _doing_it_wrong() /home/site/public_html/wp-includes/wp-db.php:995

Is this normal that the translations function are not available ?

Attachments (4)

sunrise.inc.php (8.6 KB) - added by Rahe 14 months ago.
The sunrise file
sunrise.php (6.4 KB) - added by Rahe 14 months ago.
The right sunrise file
23555.patch (912 bytes) - added by SergeyBiryukov 14 months ago.
23555.2.patch (1.5 KB) - added by SergeyBiryukov 14 months ago.

Download all attachments as: .zip

Change History (15)

Rahe14 months ago

The sunrise file

Rahe14 months ago

The right sunrise file

comment:1 SergeyBiryukov14 months ago

  • Version changed from 3.5.1 to 3.0

comment:2 SergeyBiryukov14 months ago

The _doing_it_wrong() call added in [23215] for 3.5.1 made the issue more prominent.

However, __() is only called if WP_DEBUG is true and the notices aren't disabled via a plugin:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/functions.php#L2955

comment:3 SergeyBiryukov14 months ago

There's a discussion in #21204 whether we should translate the _doing_it_wrong() messages.

comment:4 nacin14 months ago

  • Milestone changed from Awaiting Review to 3.5.2
  • Priority changed from normal to low
  • Version changed from 3.0 to 3.5.1

comment:5 chacha10214 months ago

  • Cc chacha102 added

Would it make sense in this case to add a check to _doing_it_wrong() to only translate if l10n.php has been loaded? That way in the few cases where it is called prior to l10n.php, it would be printed in English, and everywhere else translated correctly?

SergeyBiryukov14 months ago

SergeyBiryukov14 months ago

comment:6 SergeyBiryukov14 months ago

  • Keywords has-patch added

23555.patch just checks if __() exists and does nothing otherwise.

23555.2.patch checks if __() exists and falls back to untranslated strings if it doesn't.

We have a similar check in _default_wp_die_handler(): [6110], [11342].

comment:7 ryan13 months ago

Fine with 23555.2.patch​.

comment:8 nacin10 months ago

Not the cleanest solution but it'll do.

comment:9 nacin10 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 24439:

Fall back to non-translated strings in _doing_it_wrong() if the translation function doesn't exist. This may be the case in sunrise, for example.

props SergeyBiryukov.
fixes #23555.
for trunk.

comment:10 nacin10 months ago

In 24440:

Fall back to non-translated strings in _doing_it_wrong() if the translation function doesn't exist. This may be the case in sunrise, for example.

Merges [24439] to the 3.5 branch.

props SergeyBiryukov.
fixes #23555.

Note: See TracTickets for help on using tickets.