#9370 closed defect (bug) (wontfix)
PHP in get_bloginfo() - $wp_locale not setup early enough for script-loader
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8 |
Component: | Warnings/Notices | Keywords: | needs-patch |
Focuses: | Cc: |
Description
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)
Change History (20)
#2
@
16 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
@
16 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?
#5
@
16 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
@
16 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.
#8
follow-up:
↓ 9
@
16 years ago
another possibility would be to actually declare the text_direction variable in the styles class.
#9
in reply to:
↑ 8
@
16 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?
#11
@
16 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
#15
@
15 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
@
15 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.. - http://dd32.id.au/2009/11/01/youre-doing-it-wrong-1/
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.
Visible on most pages actually (which makes sense).