Skip to content

Commit

Permalink
Merge pull request #80 from normann/develop
Browse files Browse the repository at this point in the history
PostgreSQL compatible fixes
  • Loading branch information
John Milmine committed Jul 6, 2017
2 parents 7b15395 + 52522d0 commit 402af9a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions code/extensions/ElementPageExtension.php
Expand Up @@ -318,7 +318,7 @@ public function onAfterDuplicate($duplicatePage)
$duplicateWidget = $originalWidget->duplicate(true);

// manually set the ParentID of each widget, so we don't get versioning issues
DB::query(sprintf("UPDATE Widget SET ParentID = %d WHERE ID = %d", $duplicateWidgetArea->ID, $duplicateWidget->ID));
DB::query(sprintf("UPDATE \"Widget\" SET \"ParentID\" = '%d' WHERE \"ID\" = '%d'", $duplicateWidgetArea->ID, $duplicateWidget->ID));
}
}
}
Expand All @@ -340,7 +340,7 @@ public function onAfterDuplicateToSubsite($originalPage)
$duplicateWidget = $originalWidget->duplicate(true);

// manually set the ParentID of each widget, so we don't get versioning issues
DB::query(sprintf("UPDATE Widget SET ParentID = %d WHERE ID = %d", $duplicateWidgetArea->ID, $duplicateWidget->ID));
DB::query(sprintf("UPDATE \"Widget|\" SET \"ParentID\" = '%d' WHERE \"ID\" = '%d'", $duplicateWidgetArea->ID, $duplicateWidget->ID));
}
}

Expand All @@ -350,7 +350,7 @@ public function onAfterDuplicateToSubsite($originalPage)
public function onAfterPublish()
{
if ($id = $this->owner->ElementAreaID) {
$widgets = Versioned::get_by_stage('BaseElement', 'Stage', "ParentID = '$id'");
$widgets = Versioned::get_by_stage('BaseElement', 'Stage', "\"ParentID\" = '$id'");
$staged = array();

foreach ($widgets as $widget) {
Expand All @@ -360,7 +360,7 @@ public function onAfterPublish()
}

// remove any elements that are on live but not in draft.
$widgets = Versioned::get_by_stage('BaseElement', 'Live', "ParentID = '$id'");
$widgets = Versioned::get_by_stage('BaseElement', 'Live', "\"ParentID\" = '$id'");

foreach ($widgets as $widget) {
if (!in_array($widget->ID, $staged)) {
Expand All @@ -386,7 +386,7 @@ public function onBeforeRollback($version)
return;
}
if ($id = $this->owner->ElementAreaID) {
$widgets = Versioned::get_by_stage('BaseElement', 'Live', "ParentID = '$id'");
$widgets = Versioned::get_by_stage('BaseElement', 'Live', "\"ParentID\" = '$id'");
$staged = array();

foreach ($widgets as $widget) {
Expand Down

0 comments on commit 402af9a

Please sign in to comment.