Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Strange problems after update to php 5.3.8


Go to End


6 Posts   1970 Views

Avatar
danzzz

Community Member, 175 Posts

10 September 2011 at 8:32am

Edited: 10/09/2011 10:48am

hi

I just updated my php to 5.3.8 and now I have some problems.
My ModelAdmin dont work any more. I manage some models with this URL /admin/MyAdmin ....
I'm in dev mode:

[Notice] Trying to get property of non-object
GET /admin/MyAdmin/
Line 114 in /var/www/domain.com/sapphire/forms/CheckboxSetField.php

Source

105 		$options = '';
106 		
107 		if ($source == null) {
108 			$source = array();
109 			$options = "<li>No options available</li>";
110 		}
111 
112 		if($source) foreach($source as $index => $item) {
113 			if(is_a($item, 'DataObject')) {
114 				$key = $item->ID;
115 				$value = $item->Title;
116 			} else {
117 				$key = $index;
118 				$value = $item;
119 			}
120 			

Trace

    CheckboxSetField->Field()
    Line 369 of ViewableData.php
    ViewableData->obj(Field,,,)
    Line 446 of ViewableData.php
    ViewableData->XML_val(Field)
    Line 409 of FormField.php
    FormField->FieldHolder()
    Line 93 of CompositeField.php
    CompositeField->FieldHolder()
    Line 93 of CompositeField.php
    CompositeField->FieldHolder()
    Line 369 of ViewableData.php
    ViewableData->obj(FieldHolder,,,1)
    Line 446 of ViewableData.php
    ViewableData->XML_val(FieldHolder,,1)
    Line 78 of .cache.sapphire.templates.Includes.Form.ss
    include(/tmp/silverstripe-cache-var-www-domain.com/.cache.sapphire.templates.Includes.Form.ss)
    Line 420 of SSViewer.php
    SSViewer->process(Form)
    Line 342 of ViewableData.php
    ViewableData->renderWith(Array)
    Line 1108 of Form.php
    Form->forTemplate()
    Line 447 of ViewableData.php
    ViewableData->XML_val(SearchForm,,1)
    Line 31 of .cache.cms.templates.ModelSidebar.ss
    include(/tmp/silverstripe-cache-var-www-domain.com/.cache.cms.templates.ModelSidebar.ss)
    Line 420 of SSViewer.php
    SSViewer->process(ModelAdmin_CollectionController)
    Line 342 of ViewableData.php
    ViewableData->renderWith(ModelSidebar)
    Line 387 of ModelAdmin.php
    ModelAdmin_CollectionController->getModelSidebar()
    Line 258 of ModelAdmin.php
    ModelAdmin->getModelForms()
    Line 112 of ViewableData.php
    ViewableData->__get(ModelForms)
    Line 371 of ViewableData.php
    ViewableData->obj(ModelForms)
    Line 78 of .cache.cms.templates.Includes.ModelAdmin_left.ss
    include(/tmp/silverstripe-cache-var-www-domain.com/.cache.cms.templates.Includes.ModelAdmin_left.ss)
    Line 420 of SSViewer.php
    SSViewer->process(AffiliateAdmin)
    Line 342 of ViewableData.php
    ViewableData->renderWith(Array)
    Line 488 of LeftAndMain.php
    LeftAndMain->Left()
    Line 369 of ViewableData.php
    ViewableData->obj(Left,,,1)
    Line 446 of ViewableData.php
    ViewableData->XML_val(Left,,1)
    Line 59 of .cache.cms.templates.LeftAndMain.ss
    include(/tmp/silverstripe-cache-var-www-domain.com/.cache.cms.templates.LeftAndMain.ss)
    Line 420 of SSViewer.php
    SSViewer->process(AffiliateAdmin)
    Line 202 of Controller.php
    Controller->handleAction(SS_HTTPRequest)
    Line 143 of RequestHandler.php
    RequestHandler->handleRequest(SS_HTTPRequest)
    Line 147 of Controller.php
    Controller->handleRequest(SS_HTTPRequest)
    Line 282 of Director.php
    Director::handleRequest(SS_HTTPRequest,Session)
    Line 125 of Director.php
    Director::direct(/admin/MyAdmin/)
    Line 127 of main.php

Before the update there was no problem ...

1) This Notice comes even if I dont use a CheckboxSetField in the managed models (ModelAdmin uses it ...)
2) If I deactivate DEV mode, the page /admin/MyAdmin loads normaly ... but why the notice?

???

EDIT:

http://www.php.net/ChangeLog-5.php#5.3.8
There are some items where it's about "is_a" ...

also interesting:

http://roojs.com/index.php/View/242/.html
http://www.serverphorums.com/read.php?7,366375

and about 5.3.8
http://fossplanet.com/f13/%5Bfedora-php-devel-list%5D-is_a-behavior-5-3-8-a-189399/

Avatar
danzzz

Community Member, 175 Posts

10 September 2011 at 9:59am

Edited: 10/09/2011 10:01am



		    // if(is_a($item, 'DataObject')) {
		    if (is_object($item) && is_a($item, 'DataObject')) {
				$key = $item->ID;
				$value = $item->Title;
			} else {
				$key = $index;
				$value = $item;
			}

This should fix it for the moment, but it seems that there is big discussion about "is_a" ...
https://bugs.php.net/bug.php?id=55475

Avatar
martimiz

Forum Moderator, 1391 Posts

10 September 2011 at 11:36pm

If this is true, and it seems to be, this might become a problem, as is_a() is used fairly often in SilverStripe - something like 51 occurrences in 22 pages, in core alone... :-( Not to speak of upgrading all those sites... I've no sites running on 5.3.7+ just yet...

Anyone else run into trouble with this? Course of action?

Avatar
(deleted)

Community Member, 473 Posts

15 September 2011 at 10:04pm

It looks like the PHP group have reverted this change for 5.3.9 (assuming it gets released).

However, the new behaviour will be in 5.4 (there was a big discussion on it. Basically, any code using is_a() to also check for is_object() is relying on a bug), so you'll either need to put off upgrading to 5.4 or make sure is_a() is only every called on objects.

Avatar
danzzz

Community Member, 175 Posts

15 September 2011 at 11:00pm

nice to know ...

Avatar
martimiz

Forum Moderator, 1391 Posts

16 September 2011 at 3:50am

Lets hope SilverStripe 3 is longtime up, running and is_a_bug_free before that happens... :-)