Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Strange problems after update to php 5.3.8

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

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

Page: 1
Go to End
Author Topic: 1480 Views
  • danzzz
    Avatar
    Community Member
    175 Posts

    Strange problems after update to php 5.3.8 Link to this post

    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/

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: Strange problems after update to php 5.3.8 Link to this post

           // 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

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Strange problems after update to php 5.3.8 Link to this post

    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?

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Strange problems after update to php 5.3.8 Link to this post

    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.

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: Strange problems after update to php 5.3.8 Link to this post

    nice to know ...

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Strange problems after update to php 5.3.8 Link to this post

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

    1480 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.