Skip to content
Browse files

MINOR added LastCompletedWorkflow?(ID) to SiteTree (merged from r99610)

BUGFIX make the deletion report return the correct data (merged from r99610)
  • Loading branch information...
1 parent c7df33e commit f4770ecdda33d079986616503a8b3ffebaa51247 @rixth rixth committed with chillu Sep 23, 2011
View
3 code/SiteTreeCMSWorkflow.php
@@ -50,6 +50,9 @@ function extraStatics() {
'db' => array(
"ExpiryDate" => "SS_Datetime",
),
+ 'has_one' => array(
+ 'LatestCompletedWorkflowRequest' => 'WorkflowRequest'
+ ),
'has_many' => array(
// has_one OpenWorkflowRequest is implemented as custom getter
'WorkflowRequests' => 'WorkflowRequest'
View
2 code/WorkflowPublicationRequest.php
@@ -123,6 +123,8 @@ public function publish($comment, $member, $notify) {
// We have to mark as completed now, or we'll get
// recursion from SiteTreeCMSWorkflow::onAfterPublish.
$page = $this->Page();
+ $page->LatestCompletedWorkflowRequestID = $this->ID;
+ $page->writeWithoutVersion();
// Embargo means we go Approved -> Scheduled
if($this->EmbargoDate) {
View
16 code/migrations/WorkflowMigrationTask_LatestCompletedWorkflowRequestID.php
@@ -0,0 +1,16 @@
+<?php
+
+class WorkflowMigrationTask_LatestCompletedWorkflowRequestID extends BuildTask {
+ function getTitle() {
+ return 'Workflow LatestCompletedWorkflowRequestID';
+ }
+ function getDescription() {
+ return 'Rebuild the LatestCompletedWorkflowRequestID on all pages';
+ }
+ function run($request) {
+ DB::query("UPDATE SiteTree SET LatestCompletedWorkflowRequestID = (SELECT MAX(ID) FROM WorkflowRequest WHERE PageID = SiteTree.ID AND Status = 'Completed')");
+ DB::query("UPDATE SiteTree_Live SET LatestCompletedWorkflowRequestID = (SELECT MAX(ID) FROM WorkflowRequest WHERE PageID = SiteTree_Live.ID AND Status = 'Completed')");
+ echo "<p>Completed</p>";
+ }
+}
+?>
View
2 code/reports/PagesScheduledForDeletionReport.php
@@ -94,7 +94,7 @@ function sourceRecords($params, $sort, $limit) {
Versioned::reading_stage('Live');
$query = singleton("SiteTree")->extendedSQL(join(' AND ', $wheres), null, null,
- "LEFT JOIN \"WorkflowRequest\" on \"WorkflowRequest\".\"PageID\" = \"SiteTree_Live\".\"ID\""
+ 'LEFT JOIN "WorkflowRequest" on "WorkflowRequest"."ID" = "SiteTree_Live"."LatestCompletedWorkflowRequestID"'
);
View
7 doc/upgrading.md
@@ -0,0 +1,7 @@
+# Upgrading
+
+## v<next> ##
+
+ * Run `sake dev/tasks/WorkflowMigrationTask_LatestCompletedWorkflowRequestID` in order to
+ populate the latest workflow request relationship for existing requests (in the `SiteTree_live` table).
+ This is required e.g. for `PagesScheduledForDeletionReport` to correctly view data.

0 comments on commit f4770ec

Please sign in to comment.
Something went wrong with that request. Please try again.