Skip to content

Commit

Permalink
BUGFIX MigrateSiteTreeLinkingTask now takes a direct map when queryin…
Browse files Browse the repository at this point in the history
…g the page tracked links instead of looping through the direct result set. This fixes SQL Server failing when MARS (Multiple Active Result Sets) is disabled

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@110197 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sean Harvey authored and Sam Minnee committed Feb 2, 2011
1 parent 3a210c3 commit 5160c8a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tasks/MigrateSiteTreeLinkingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ public function run($request) {
if($linkedPages) $linkedPages->removeDuplicates();

if($linkedPages) foreach($linkedPages as $page) {
$tracking = DB::query(sprintf (
'SELECT "ChildID", "FieldName" FROM "SiteTree_LinkTracking" WHERE "SiteTreeID" = %d',
$page->ID
));

foreach($tracking as $link) {
$linked = DataObject::get_by_id('SiteTree', $link['ChildID']);
$tracking = DB::query(sprintf('SELECT "ChildID", "FieldName" FROM "SiteTree_LinkTracking" WHERE "SiteTreeID" = %d', $page->ID))->map();

foreach($tracking as $childID => $fieldName) {
$linked = DataObject::get_by_id('SiteTree', $childID);

// TOOD: Replace in all HTMLText fields
$page->Content = preg_replace (
Expand All @@ -48,8 +45,8 @@ public function run($request) {
$links += $replaced;
}
}
$page->write();

$page->write();
$pages++;
}

Expand Down

0 comments on commit 5160c8a

Please sign in to comment.