Home › Support › English Support › [Resolved] Calling icl_get_languages causes crash in wordpress 3.5
Tagged: crash, icl_get_languages, wordpress
This topic contains 0 replies, has 3 voices, and was last updated by benedetto 4 months, 3 weeks ago. The support staff assigned to this topic is Harshad.
| Author | Posts |
|---|---|
| Author | Posts |
| December 17, 2012 at 5:50 pm #91387 | |
|
benedetto |
Hi guys, i have this problem: If i assign the array of icl_get_languages() to a variable or costant ( with serialize ) within functions.php, the entire wordpress frontend crash. I can't see any output. I have the latest version of wpml ( 2.6.2 ) and the latest version of string translator ( 1.5.2 ) and WordPress 3.5 I hope you can help me |
| December 18, 2012 at 6:15 am #91472 | |
|
Harshad |
Can you please paste the code here, that you are using in your theme functions? |
| December 18, 2012 at 8:47 am #91528 | |
|
benedetto |
This is the code i use in my functions.php define( 'TEMAURL' , get_bloginfo( 'template_url' ) );
define( 'ABSTEMA' , dirname( __FILE__ ) );
define( 'SHORTNAME' , strtolower( substr( get_bloginfo( 'name' ) , 0 , 1 ) . substr( get_bloginfo( 'name' ) , -1 ) ) );
define( 'THEMENAME' , get_bloginfo( 'name' ) );
define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );
add_theme_support( 'post-thumbnails' );
add_post_type_support('page', 'excerpt');
register_nav_menu( 'topmenu', 'Top Menù' );
If i comment this out define( 'ARRAY_LANG' , serialize( icl_get_languages() ) ); everything is going to work fine. |
| December 18, 2012 at 11:30 am #91603 | |
|
Harshad |
Dear Benedetto, I sued the same code in my theme's functions.php file define( 'ARRAY_LANG' , serialize( icl_get_languages() ) ); At my local install, its working fine without any crash, If I output the constant ARRAY_LANG, I can see the serialized data. Can you please enable a PHP error log file and check what's there? From this page: Edit your wp-config.php file and add these lines, just before it says 'stop editing here': ini_set('log_errors',TRUE); This will create an error_log.txt file in your site's root directory. Let's see what it includes. |
| December 18, 2012 at 2:11 pm #91675 | |
|
benedetto |
Thanks Harshad for your reply: i did exactly what you said to do, and the only output in error_log.txt is [18-Dec-2012 13:59:04 UTC] PHP Notice: Undefined index: name in /web/htdocs/www.enuage.it/home/wp-includes/query.php on line 3569 That output is also visible when wp_debug is set to true. If it can help you, im going to attach my home status when icl_get_languages is declared and when it is commented out. |
| December 19, 2012 at 6:06 am #91818 | |
|
Harshad |
Dear Benedetto, I need to troubleshoot further, is it possible for you to send me your sites ftp and wp-admin details to my email address? Please include this forum link for reference. |
| December 19, 2012 at 10:54 am #91907 | |
|
benedetto |
Hi Harshad, unfortunately i can't give you those details, but i can give you some information about debugging: I tried WP 3.4.2 with the latest version of wpml and string translator, and it works fine. Upgrading WP from 3.4.2 to 3.5 causes the crash of the frontend when i declare that define. I suppose, then, some incompatibility with the new WP. I'll attach my results as image and i'll send to your email the theme i'm using. |
| December 20, 2012 at 8:04 am #92172 | |
|
Harshad |
Dear Benedetto, I have sent you email, with dev version WPML CMS attached, please download the attachment. De-activate and delete existing WPML CMS version from plugins menu then upload the attached dev version and activate it. Let me know if this helps. |
| December 20, 2012 at 10:33 am #92229 | |
|
benedetto |
Ok, with the new version you sent to me, it doesn't crash in 3.5 Hovewer icl_get_languages() returns " a:0:{} " when defined in functions.php, but i guess it's not a big problem to solve The theme is always the same. I'll attach the output. |
| December 20, 2012 at 1:45 pm #92307 | |
|
Harshad |
Can you switch your theme to default twenty twelve and use the code below and check? define( 'ARRAY_LANG' , serialize( icl_get_languages() ) ); print_r(ARRAY_LANG); |
| December 20, 2012 at 2:15 pm #92314 | |
|
benedetto |
I switched to Twenty Twelve and added that code in functions.php of the theme itself at the very top ( as you can see in the attachment) ; the output is the same: " a:0:{} " |
| December 20, 2012 at 2:44 pm #92327 | |
|
Harshad |
That's strange at my end I can see the serialized array |
| December 20, 2012 at 4:13 pm #92363 | |
|
benedetto |
Very very strange. I've installed wp 3.5 and just wpml on a remote server ( maybe wamp was not configurated properly ) and still that array is empty. However i find that declaring define( 'ARRAY_LANG' , serialize( icl_get_languages() ) ); outside functions.php ( like header.php ) , makes print_r( ARRAY_LANG ) to work fine. Also i tried this, in function.php this time: function test(){
if( function_exists( 'icl_get_languages' ) )
define( 'ARRAY_LANG ' , serialize( icl_get_languages() ) );
}
add_action('wp_head','test');
and in this case the array is NOT empty. My issue is half resolved, by the way |
| December 21, 2012 at 10:08 am #92603 | |
|
Harshad |
My issue is half resolved, by the way Can you please let us know the pending issues |
| December 26, 2012 at 9:16 am #93100 | |
|
benedetto |
Well, at the moment i can use the serialized array only when it is declared into an output hook, such as wp_head. However declaring that costant inside functions.php, without any hook, or if i use other hooks, such as init o after_theme_setup, it doesn't make the array to be assigned This is my screenshot. |
You must be logged in to reply to this topic.





