Skip to content

Commit 2dc2699

Browse files
committed
Merge branch 'craft-4' of https://github.com/verbb/workflow into craft-5
# Conflicts: # CHANGELOG.md # composer.json
2 parents be3a422 + adb64b5 commit 2dc2699

File tree

11 files changed

+51
-9
lines changed

11 files changed

+51
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
- Now requires PHP `8.2.0+`.
4444
- Now requires Craft `5.0.0+`.
4545

46+
## 2.0.13 - 2024-11-28
47+
48+
### Fixed
49+
- Fix when deleting a Craft User that owned a review, would also delete that review.
50+
- Fix an error when approving a submission. (thanks @iainsaxon).
51+
4652
## 2.0.12 - 2024-10-09
4753

4854
### Fixed

src/Workflow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Workflow extends Plugin
4343
// =========================================================================
4444

4545
public bool $hasCpSettings = true;
46-
public string $schemaVersion = '2.5.0';
46+
public string $schemaVersion = '2.6.0';
4747
public string $minVersionRequired = '1.7.0';
4848

4949

src/elements/Submission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function getSupportedSites(): array
187187
return $owner->getSupportedSites();
188188
}
189189

190-
return Craft::$app->getSites()->getAllSites();
190+
return Craft::$app->getSites()->getAllSiteIds();
191191
}
192192

193193
public function setOwner(Entry $owner): void

src/migrations/Install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function addForeignKeys(): void
8181
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementId', '{{%elements}}', 'id', 'SET NULL', null);
8282
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementSiteId', '{{%sites}}', 'id', 'CASCADE', null);
8383
$this->addForeignKey(null, '{{%workflow_reviews}}', 'draftId', '{{%drafts}}', 'id', 'SET NULL', null);
84-
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'CASCADE', null);
84+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'SET NULL', null);
8585
}
8686

8787
public function dropTables(): void
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace verbb\workflow\migrations;
3+
4+
use craft\db\Migration;
5+
use craft\db\Query;
6+
use craft\helpers\MigrationHelper;
7+
8+
use Throwable;
9+
10+
class m241030_000000_user_fk extends Migration
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function safeUp(): bool
16+
{
17+
MigrationHelper::dropAllForeignKeysOnTable('{{%workflow_reviews}}');
18+
19+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'submissionId', '{{%workflow_submissions}}', 'id', 'CASCADE', null);
20+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementId', '{{%elements}}', 'id', 'SET NULL', null);
21+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementSiteId', '{{%sites}}', 'id', 'CASCADE', null);
22+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'draftId', '{{%drafts}}', 'id', 'SET NULL', null);
23+
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'SET NULL', null);
24+
25+
return true;
26+
}
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
public function safeDown(): bool
32+
{
33+
echo "m241030_000000_user_fk cannot be reverted.\n";
34+
return false;
35+
}
36+
}

src/models/Review.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function getUserUrl(): ?Markup
178178
return Template::raw($user);
179179
}
180180

181-
return null;
181+
return Template::raw(Craft::t('workflow', '[Deleted User]'));
182182
}
183183

184184
public function getStatusName(): ?string

src/templates/_sidebar/_layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<div id="{{ anchorKey }}" class="workflow-history-info hidden">
3939
<div class="instructions">
40-
<p>{{ review.userUrl }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>
40+
<p>{{ review.getUserUrl() }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>
4141

4242
{% if review.notes %}
4343
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>

src/templates/_sidebar/publisher-pane.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<div id="workflow-submission-info" class="hidden">
1515
<div class="instructions">
16-
<p>{{ review.userUrl }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
16+
<p>{{ review.getUserUrl() }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
1717

1818
{% if review.notes %}
1919
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>

src/templates/_sidebar/reviewer-pane.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<div id="workflow-submission-info" class="hidden">
1616
<div class="instructions">
17-
<p>{{ review.userUrl }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
17+
<p>{{ review.getUserUrl() }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
1818

1919
{% if review.notes %}
2020
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>

src/templates/reviews/_includes/_review.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% set statusText = (review.status == 'pending') ? 'created' | t('workflow') : review.status %}
33

44
<div class="workflow-compare-review-heading">
5-
<label class="review-count">{{ review.userUrl }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</label>
5+
<label class="review-count">{{ review.getUserUrl() }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</label>
66
<label class="review-status-badge {{ review.status }}">{{ statusText }}</label>
77
</div>
88

0 commit comments

Comments
 (0)