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.

Archive /

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

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

version 2.3.0 rc1 - VirtualPage Status CMS error


Go to End


1396 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

27 November 2008 at 6:03am

Edited: 27/11/2008 6:03am

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)
	)
),