Some mistakes with php version?

On My PC I have tried to modify CActiveRecord::model() because there is strange behavior in my website when is on server that is in production:

(only var_dump were added)

  public static function model($className=__CLASS__) {

    if (isset(self::$_models[$className])) {

      return self::$_models[$className];

    } else {

      $model = self::$_models[$className] = new $className(null);


      $model->_md = new CActiveRecordMetaData($model);


      return $model;



This is what I see on my PC

ubuntu 10.04

php 5.2.3

object(Automobili)#20 (13) {

["immagine"]=> NULL 

["_md":"CActiveRecord":private]=> NULL 

["_new":"CActiveRecord":private]=> bool(false) 

["_attributes":"CActiveRecord":private]=> array(0) { } 

["_related":"CActiveRecord":private]=> array(0) { } 

["_c":"CActiveRecord":private]=> NULL 

["_pk":"CActiveRecord":private]=> NULL 

["_alias":"CActiveRecord":private]=> string(1) "t" 

["_errors":"CModel":private]=> array(0) { } 

["_validators":"CModel":private]=> NULL 

["_scenario":"CModel":private]=> string(0) "" 

["_e":"CComponent":private]=> NULL 

["_m":"CComponent":private]=> NULL }

This is what I see online

ubuntu 6.06

php 5.1.2

object(Automobili)#19 (13) { 

["immagine"]=> NULL 

["_md:private"]=> NULL 

["_new:private"]=> bool(false) 

["_attributes:private"]=> array(0) { } 

["_related:private"]=> array(0) { } 

["_c:private"]=> NULL 

["_pk:private"]=> NULL 

["_alias:private"]=> string(1) "t" 

["_errors:private"]=> array(0) { } 

["_validators:private"]=> NULL 

["_scenario:private"]=> string(0) "" 

["_e:private"]=> NULL 

["_m:private"]=> NULL }

Any suggestion? php 5.1.2 is the up to date php version for 6.06. Upgrade maybe is a risk.

What’s wrong with the output? Do you have anything actually broken?

In My website when I load model and do var_dump($model) I see different things.

When I try to upload images, file name is lost in the void. File saved is "Object# 44" and not "foo.jpg". The object contains dimensions, extension … but no file name. So I tried to analyze code. On my PC I alwais see the type of vars of models. In upload, I see the file is CUploadedFile but online I dont see that. I think this makes some trouble in code. Yii or some classes dont see a property … so generate an exception.

When I see different output dumping model, I get worried.

As you can see, values from your dumps are exactly the same. What’s different is output format. There were some fixes for var_dump between 5.1.2 and 5.2.3: so maybe dump format was changed.

So it’s better to start from the start and show your controller, view and model.

I know! I’ve read all the stuff of var_dump in that page. Controller is ok. Now I’ve create another Virtual Machine with same server and php version. Generates the same error. So, now I try to upgrade PHP. If mistakes get out, the reasons of all the stuff are that CUploadedFile do not work with php 5.1.2. But the reason of why … is out of my understanding.

Can’t tell this either since I don’t have your code.

I think I got what is wrong here…

CUploadedFile uses a magic method __toString()…

Checking this documentation -…oop5.magic.php

It say that in PHP before 5.2.0 that method worked only for echo() or print()


Can you check it?

Can’t… I don’t have the 5.1.x PHP version…

sensoorario posted the code in the Italian section, you can see it here -

And note that on the above posted PHP doc. link… that info is not a user contributed content… but official PHP documentation

here is the quote:

I see. Yes, it’s PHP 5.1 limitation and you should write code in the way mdomba posted in Italian section.



usage described in the guide or wiki?

I really don’t know where I got that (could be from an forum post example, but it was a long time ago that I needed that)…

that is the way I’m used it in one project, did not need it afterwards…

so the solution is to use a temporary variable to hold the CUploadedFile instance like:


and when a filename is needed: