Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » version 2.3.0 rc1 - VirtualPage Status CMS error

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 907 Views
  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    version 2.3.0 rc1 - VirtualPage Status CMS error Link to this post

    In the CMS, when clicking on a page that has a VirtualPage pointing to it, I get the following (popup) error:

    ERROR [Notice]: Trying to get property of non-object
    IN POST /admin/getitem?ID=11&ajax=1
    Line 1117 in /undisclosedRoot/sapphire/core/model/SiteTree.php

    Source
    ======
    1108:      // Status / message
    1109:      // Create a status message for multiple parents
    1110:      if($this->ID && is_numeric($this->ID)) {
    1111:         $linkedPages = DataObject::get("VirtualPage", "CopyContentFromID = $this->ID");
    1112:      }
    1113:
    1114:      if(isset($linkedPages)) {
    1115:         foreach($linkedPages as $linkedPage) {
    1116:            $parentPage = $linkedPage->Parent;
    * 1117:            $parentPageTitle = $parentPage->Title;
    1118:
    1119:            if($parentPage->ID) {
    1120:               $parentPageLinks[] = "<a class=\"cmsEditlink\"
    href=\"admin/show/$linkedPage->ID\">{$parentPage->Title}</a>";
    1121:            } else {
    1122:               $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/$linkedPage->ID\">" .
    1123:                  _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') .

    <ul>SiteTree->getCMSFields(CMSMain)
    line 375 of CMSMain.php

    CMSMain->getEditForm(11)
    line 740 of LeftAndMain.php

    LeftAndMain->EditForm()
    line 245 of LeftAndMain.php

    LeftAndMain->getitem(HTTPRequest)
    line 164 of Controller.php

    Controller->handleAction(HTTPRequest)
    line 107 of RequestHandler.php

    RequestHandler->handleRequest(HTTPRequest)
    line 124 of Controller.php

    Controller->handleRequest(HTTPRequest)
    line 246 of Director.php

    Director::handleRequest(HTTPRequest,Session)
    line 106 of Director.php

    Director::direct(admin/getitem)
    line 88 of main.php

    </ul>

    Exception:
    This will not happen when Page and its VirtualPage share the same parent, but in real life this will probably never be the case

    Possible solution:
    It seems that in line 1117 $parentPage->Title is not an object because in line 1116 the $linkedPage->Parent property does not exist. $linkedPage has access to a Parent() method however, that will return a proper parentobject. Possible replacement in SiteTree.php line 1116:

    $parentPage = $linkedPage->Parent;

    becomes (seems to be working):

    $parentPage = $linkedPage->Parent();

    Addition: status message
    As far as I understand this code is meant to extend the status message, to tell the user that a page has VirtualPages pointing to it, and where they might be found. This statusmessage, that also holds information about the published state of a page, is never shown. This is not a bug, the code is commented, but gives an error when uncommented:

    line 1273:
    //new NamedLabelField("Status", $message, "pageStatusMessage", true)

    I wanted to see what the message was all about so to show it in the reports section of the page I did the following. It works and didn't result in any errors as yet, but just as a temporary thing:

    line 1253:

    $tabReports = new TabSet('Reports',
       $tabBacklinks =new Tab('Backlinks',
          new LiteralField("Backlinks", $backlinks)
       )
    ),

    becomes:

    $tabReports = new TabSet('Reports',
       $tabBacklinks =new Tab('Backlinks',
          new LiteralField("Backlinks", $backlinks),
          new LiteralField("Status", $message)
       )
    ),

    907 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.