verbb / workflow

A Craft CMS plugin to create a workflow for publishing entries.
Other
140 stars 27 forks source link

Status not saving after change and save - new entry edit screen in workflow #175

Closed green17 closed 1 year ago

green17 commented 1 year ago

Describe the bug

Status not saving after change and save - new entry edit screen in workflow /admin/workflow/submissions/edit/XXXXX

Steps to reproduce

  1. View an entry that needs to be approved eg /admin/workflow/submissions/edit/XXXXX
  2. Click the dropdown right-hand side to change the status then hit save. It looks like it saves but the status does not get saved.

Craft CMS version

4.2.5.1

Plugin version

2.0.1

Multi-site?

No

Additional context

No response

engram-design commented 1 year ago

Duplicate of https://github.com/verbb/workflow/issues/168, can you try 2.0.2?

green17 commented 1 year ago

Hi @engram-design I upgraded to 2.0.2 but then some entries in the workflow give this error - just viewing them:

Diff\Differ\MapDiffer::doDiff(): Argument #1 ($oldValues) must be of type array, null given, called in /vendor/verbb/workflow/src/services/Content.php on line 39

green17 commented 1 year ago

Also the link to the entry is missing now on the right hand menu in /admin/workflow/submissions/edit/XXXXX

engram-design commented 1 year ago

The error should be fixed for the next release. To get the fix early, change your verbb/workflow requirement in composer.json to:

"require": {
  "verbb/workflow": "dev-craft-4 as 2.0.2,
  "...": "..."
}

Then run composer update.

As for the missing entry in the sidebar, what state is your submission? Pending, in review or approved? If you look up the ID of the submission (the XXXXX part) in your workflow_submissions database table, is there a value for ownerId?

Once scenario where this might happen is that you've created a submission on an already-published entry (creating a new draft), and if approved, the draft will be deleted, but applying (overwriting) the original entry. But even in that instance, it should refer back to the canonical entry, instead of the now-deleted draft.

green17 commented 1 year ago

Yes there is an ID in ownerId in the DB, the id if looked up in entires works fine too. On the staging site it works for the 2.0.1 plugin version, we have a copy of the staging site DB for the local dev and it does not show on any of these pages - /admin/workflow or /admin17/workflow/submissions/edit/XXXXX.

If I do a new submission for review on an entry that is completely new it still does not work?

engram-design commented 1 year ago

Strange! I've done a whole lot of submissions in multiple scenarios, checking each step along the way, and there's always a reference to the entry.

It should fetch the last review's draft. If you can look at the workflow_review database table, for the submissionId column to match the submission you are referring to, there should be both an elementId and a draftId.

image

Regardless, I've added support for things to fallback on the owner, when a draft doesn't exist, which should help. Run composer update again to get this fix.

green17 commented 1 year ago

The fallback fixes it thanks. :-)

When I looked up a few some have no elementId or draftId, some have no draft id but have a elementId then some have both. If I look up one submissionId that has an edit/review/publish the edit/publish is blank for elementId or draftId and then the review had a elementId but no draftId.

image

engram-design commented 1 year ago

Fixed in 2.0.3