1043 Posts in 379 Topics by 373 members
Upgrading SilverStripe
SilverStripe Forums » Upgrading SilverStripe » Running /dev/tasks/MigrateSiteTreeLinkingTask failing: [Notice] Trying to get property of non-object
Ask questions about upgrading SilverStripe to the latest version.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1047 Views |
-
Running /dev/tasks/MigrateSiteTreeLinkingTask failing: [Notice] Trying to get property of non-object

5 June 2010 at 12:33pm
After upgrading to SS 2.4, I'm trying to run the nested URL migration task as described here: http://doc.silverstripe.org/sitetree#nested_hierarchical_urls
However, I am getting the following notice/trace and the process fails to do its job:
[Notice] Trying to get property of non-object
GET /dev/tasks/MigrateSiteTreeLinkingTaskLine 40 in /Users/Me/Sites/thesite/sapphire/tasks/MigrateSiteTreeLinkingTask.php
Source
31 'SELECT "ChildID", "FieldName" FROM "SiteTree_LinkTracking" WHERE "SiteTreeID" = %d',
32 $page->ID
33 ));
34
35 foreach($tracking as $link) {
36 $linked = DataObject::get_by_id('SiteTree', $link['ChildID']);
37
38 // TOOD: Replace in all HTMLText fields
39 $page->Content = preg_replace (
40 "/href *= *([\"']?){$linked->URLSegment}\/?/i",
41 "href=$1[sitetree_link id={$linked->ID}]",
42 $page->Content,
43 -1,
44 $replaced
45 );
46
TraceMigrateSiteTreeLinkingTask->run(SS_HTTPRequest)
Line 57 of TaskRunner.php
TaskRunner->runTask(SS_HTTPRequest)
Line 134 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
Line 152 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
Director::direct(/dev/tasks/MigrateSiteTreeLinkingTask)
Line 127 of main.phpHas anyone had a similar experience that could point me in the right direction?
-
Re: Running /dev/tasks/MigrateSiteTreeLinkingTask failing: [Notice] Trying to get property of non-object

6 June 2010 at 11:58am
Looks like you have a link to a page which doesn't exist in your Content really the following
// MigrateSiteTreeLinkingTask.php
$linked = DataObject::get_by_id('SiteTree', $link['ChildID']);
// TOOD: Replace in all HTMLText fields
$page->Content = preg_replace (
"/href *= *([\"']?){$linked->URLSegment}\/?/i",
"href=$1[sitetree_link id={$linked->ID}]",
$page->Content,
-1,
$replaced
);Should be something like
// MigrateSiteTreeLinkingTask.php
$linked = DataObject::get_by_id('SiteTree', $link['ChildID']);
$linkedID = ($linked) ? $linked->ID : $link['ChildID'];
$linkedURL = ($linked) ? $linked->URLSegment : '';// TOOD: Replace in all HTMLText fields
$page->Content = preg_replace (
"/href *= *([\"']?){$linkedURL}\/?/i",
"href=$1[sitetree_link id={$linkedID}]",
$page->Content,
-1,
$replaced
);Try that and see if that helps.
-
Re: Running /dev/tasks/MigrateSiteTreeLinkingTask failing: [Notice] Trying to get property of non-object

9 June 2010 at 4:45am
Thanks for your help. I tried your suggestion and it worked for some links but not all. Upon running the link migration task a second time, it added some duplicate link code (I backed up of course, so no big deal).
Another related question - how are 301 redirects handled from old URLS? Or are they?
-
Re: Running /dev/tasks/MigrateSiteTreeLinkingTask failing: [Notice] Trying to get property of non-object

9 June 2010 at 8:59am
AFAIK all the old URLs are saved from the versions table any requests to those are sent as 301 redirects to the new nested structure.
| 1047 Views | ||
|
Page:
1
|
Go to Top |


