Yii::app()->getTheme() is null on PHP 5.1.6

Hi!

Don’t know if this is a bug or just me being stupid. At least, I can’t find a good reason for it.

I working on two webapps, using Debian Lenny and PHP 5.2.6.

Now I tried to run them on CentOS 5.3, which has 5.1.6. I tar’ed the apps from a testing server, where they work just fine, and moved them over to the CentOS. Now, both apps fail on using theming, saying cannot access a property on a non object:

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->getTheme()->baseUrl; ?>/css/theme.css" />

I comment it out and the apps work without any problems. I checked and in fact Yii::app()->theme is null. Have no idea why this happens, so I would like to ask. Yii Version is 1.0.8.

By default, I’m not using a theme.

Cheers,

Hein

What is the result if you set it explicitly in your controller?

Found it! After getting a few hours sleep I found the very good reason for it :)

First of all, not using a theme always makes the themeManager being null, so says the doc. So it must be a configuration issue.

There are quite a few differences between the distribution php.ini’s, but the one that hits here is that Lenny has




error_reporting = E_ALL & ~E_NOTICE



where CentOS has




error_reporting = E_ALL



Setting Lenny to the same value as CentOS makes the script stop at the same issue as on Cent.

Here are the different config values for both of the systems, how they come in on install. Some of them can really hit you.




php.lenny.ini     : precision = 12;

  php.centos.ini  : precision = 14

php.lenny.ini     : output_buffering = ;

  php.centos.ini  : output_buffering = 4096

php.lenny.ini     : allow_call_time_pass_reference = 1;

  php.centos.ini  : allow_call_time_pass_reference =

php.lenny.ini     : memory_limit = 128M;

  php.centos.ini  : memory_limit = 16M

php.lenny.ini     : error_reporting = 6135;

  php.centos.ini  : error_reporting = 6143

php.lenny.ini     : display_errors = 1;

  php.centos.ini  : display_errors =

php.lenny.ini     : log_errors = ;

  php.centos.ini  : log_errors = 1

php.lenny.ini     : register_long_arrays = 1;

  php.centos.ini  : register_long_arrays =

php.lenny.ini     : register_argc_argv = 1;

  php.centos.ini  : register_argc_argv =

php.lenny.ini     : magic_quotes_gpc = 1;

  php.centos.ini  : magic_quotes_gpc =

php.lenny.ini     : enable_dl = ;

  php.centos.ini  : enable_dl = 1

php.lenny.ini     : session.gc_divisor = 100;

  php.centos.ini  : session.gc_divisor = 1000

php.lenny.ini     : session.bug_compat_42 = 1;

  php.centos.ini  : session.bug_compat_42 = 0

php.lenny.ini     : session.hash_bits_per_character = 4;

  php.centos.ini  : session.hash_bits_per_character = 5

php.lenny.ini     : url_rewriter.tags = a=href,area=href,frame=src,input=src,form=,fieldset=;

  php.centos.ini  : url_rewriter.tags = a=href,area=href,frame=src,input=src,form=fakeentry




Cheers,

Hein