Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9370 closed defect (bug) (wontfix)

PHP in get_bloginfo() - $wp_locale not setup early enough for script-loader

Reported by: viper007bond's profile Viper007Bond Owned by: westi's profile westi
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Warnings/Notices Keywords: needs-patch
Focuses: Cc:


Visable from the write post page:

Notice: Trying to get property of non-object in [...]\wp-includes\general-template.php on line 330

Attachments (1)

9370.patch (455 bytes) - added by Viper007Bond 14 years ago.

Download all attachments as: .zip

Change History (20)

#1 @Viper007Bond
14 years ago

Visible on most pages actually (which makes sense).

14 years ago

#2 @Viper007Bond
14 years ago

  • Keywords has-patch added; needs-patch removed

Looks like get_bloginfo() is being called somewhere before WP_Locale is initiated. Attached patch returns a blank string if the class/var hasn't been initiated yet. Hopefully this doesn't break anything, although it's no different from what's currently going on.

#3 @westi
14 years ago

  • Owner changed from anonymous to westi
  • Status changed from new to assigned

I can't see this is my testbed - is it plugin related?

#4 @westi
14 years ago

  • Milestone changed from Future Release to 2.8

#5 @Viper007Bond
14 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed

Whoops, didn't even occur to me to check as I only had my own plugin activated.

Off to debug.

#6 @Viper007Bond
14 years ago

  • Milestone set to 2.8
  • Resolution invalid deleted
  • Status changed from closed to reopened

WordPress bug triggered by my plugin. I guess it's registering/enqueueing styles before the locale class is initiated.

The issue comes from this line in script-loader.php:

$styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';

If I comment that out (or my wp_enqueue_style()'s), the error goes away. Waiting until "init" rather than "plugins_loaded" also fixes the problem, so I guess it was partially my fault.

#7 @Denis-de-Bernardy
14 years ago

  • Keywords commit added

can't test myself, but I'm sure it can make it into 2.8 :-)

#8 follow-up: @Denis-de-Bernardy
14 years ago

another possibility would be to actually declare the text_direction variable in the styles class.

#9 in reply to: ↑ 8 @Denis-de-Bernardy
14 years ago

  • Keywords 2nd-opinion added; commit removed

Replying to Denis-de-Bernardy:

another possibility would be to actually declare the text_direction variable in the styles class.

err... nevermind that. :-)

might we not want to initialize $wp_locale rather than return an erroneous value?

#10 @ryan
14 years ago

  • Component changed from General to Warnings/Notices

#11 @westi
14 years ago

  • Keywords needs-patch added; has-patch 2nd-opinion removed
  • Priority changed from lowest to normal
  • Summary changed from PHP notice for get_bloginfo() to PHP in get_bloginfo() - $wp_locale not setup early enough for script-loader

It sounds better to have the correct local info rather than return dodgy data here.

Marking back as needs-patch

#12 @Denis-de-Bernardy
14 years ago

  • Milestone changed from 2.8 to Future Release

Future, pending patch

#14 @Denis-de-Bernardy
14 years ago

  • Milestone changed from Future Release to 2.9

#15 @Code_M3
14 years ago

  • Severity changed from minor to normal

I observed the same issue, it's causing any RTL blog that has plugins which use the function wp_enqueue_style to switch it's style direction to LTR in the admin panel as soon as the plugin is activated.

I found that if any plugin uses this function it'll cause get_bloginfo( 'text_direction' ) in wp-includes/script-loader.php to return the current WordPress version instead of either 'rtl' or 'ltr'. Which doesn't make sense!

After some more debugging I found that the global variable 'text_direction' is not setup up early enough for script-loader.php to load the correct data which is either 'rtl' or 'ltr' depends on the locale.

#16 @dd32
14 years ago

I'm not sure why this ticket is still open..

using wp_enqueue_script() before init is a recipe for disaster, I came accross a plugin which was doing exactly that a few days ago and sent me on a wild goose chase trying to work out what was happening to make wp_styles spit out errors.. -

In my opinion: The fix is to just return false if someone tries to enqueue too early.. They obviously dont care what page their output is going to appear on.. so they're broken already.

#17 @azaozz
14 years ago

  • Resolution set to wontfix
  • Status changed from reopened to closed

Agree with dd32, this seems caused by improper use of wp_enqueue_script() or wp_enqueue_style().

#18 @lloydbudd
14 years ago

  • Milestone changed from 2.9 to Unassigned

#19 @dd32
14 years ago

  • Milestone Unassigned deleted
Note: See TracTickets for help on using tickets.