Workflow history has disappeared after upgrading from 8.x-1.7 to 2.0.0

Created on 9 June 2025, 4 months ago

Problem/Motivation

Workflow history in Workflow tab of each content has disappeared after upgrading from 8.x-1.7 to 2.0.0
On the other hand, preview of Workflow history in /admin/structure/views/view/workflow_entity_history still appears.
Could you take a look at this?

- Drupal 10.4.6
- workflow: 2.0.0
- workflow_notification: 3.0.0-beta5 (not completely compatible with workflow 2.0.0)
- PHP: 8.3.21

workflow 2.0.0: HTML text around workflow history in Workflow tab (no table data)

<div class="views-element-container">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view' -->
<!-- BEGIN OUTPUT from 'themes/contrib/bartik/templates/classy/views/views-view.html.twig' -->
<div class="view view-workflow-entity-history view-id-workflow_entity_history view-display-id-workflow_history_tab js-view-dom-id-e357989d6958c2128d169399d2a5a819841a1fa530e68c93cddae97a7d84e3d3">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'pager' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/pager.html.twig' -->
<!-- END OUTPUT from 'core/modules/system/templates/pager.html.twig' -->
</div>
<!-- END OUTPUT from 'themes/contrib/bartik/templates/classy/views/views-view.html.twig' -->
</div>

workflow 8.x-1.7: HTML text around workflow history in Workflow tab (table data exist)

<div class="views-element-container">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view' -->
<!-- BEGIN OUTPUT from 'themes/contrib/bartik/templates/classy/views/views-view.html.twig' -->
<div class="view view-workflow-entity-history view-id-workflow_entity_history view-display-id-workflow_history_tab js-view-dom-id-a1eb1bf82531f9248327e572ababb967f81432def497f575d59147b3c5493e6c">
<div class="view-content">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_table__workflow_entity_history' -->
<!-- FILE NAME SUGGESTIONS:
 - views-view-table--workflow-entity-history.html.twig
 - views-view-table--workflow-entity-history.html.twig
 v views-view-table.html.twig
-->
<!--  BEGIN CUSTOM TEMPLATE OUTPUT from 'themes/custom/bartik_custom/templates/views-view-table.html.twig' -->
<table class="views-table views-view-table cols-6">
<thead>
<tr>
<th id="view-timestamp-table-column" class="views-field views-field-timestamp" scope="col">Date</th>
<th id="view-from-sid-table-column" class="views-field views-field-from-sid" scope="col">From</th>
<th id="view-to-sid-table-column" class="views-field views-field-to-sid" scope="col">To</th>
<th id="view-uid-table-column" class="views-field views-field-uid" scope="col">Name</th>
<th id="view-comment-table-column" class="views-field views-field-comment" scope="col">Comment</th>
<th id="view-langcode-table-column" class="views-field views-field-langcode" scope="col">Lang</th>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
<!-- END CUSTOM TEMPLATE OUTPUT from 'themes/custom/bartik_custom/templates/views-view-table.html.twig' -->
</div>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'pager' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/pager.html.twig' -->
<!-- END OUTPUT from 'core/modules/system/templates/pager.html.twig' -->
</div>
<!-- END OUTPUT from 'themes/contrib/bartik/templates/classy/views/views-view.html.twig' -->
</div>

Steps to reproduce

1. Upgrade from 8.x-1.7 to 2.0.0
composer require 'drupal/workflow:^2.0'
drush updb
drush cr
2. See Workflow tab of a content. Workflow history disappears.

Proposed resolution

Reverse to 8.x-1.7.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kubokura
  • 🇳🇱Netherlands johnv

    Please test again with new version 2.1.0 and report your findings.

  • @johnv, thank you for your response. Unfortunately the symptom is reproduced with version 2.1.0.

  • 🇳🇱Netherlands johnv

    Hmm, I wonder why this is note reported more often.
    Perhaps it is the same problem as 🐛 Upgrading from 1.7 to 1.8 Active .

    At some point, the programmed History view was replaced by a View (with still a fallback to the programmed list.)
    Do you have a customized History view?
    Please check page admin/structure/views/view/workflow_entity_history

  • 🇨🇭Switzerland ayalon

    I have no changes in the workflow_entity_history but If I try to load the history I get a fatal error. This error is also triggered if I open the view and add an example node in the context filter:

    
    Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Arbeitsablaufentitätenverlauf[workflow_entity_history]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.force' in 'SELECT': SELECT "base"."hid" AS "hid", "base"."wid" AS "wid", "base"."langcode" AS "langcode", "base"."entity_type" AS "entity_type", "base"."entity_id" AS "entity_id", "base"."revision_id" AS "revision_id", "base"."field_name" AS "field_name", "base"."delta" AS "delta", "base"."uid" AS "uid", "base"."from_sid" AS "from_sid", "base"."to_sid" AS "to_sid", "base"."timestamp" AS "timestamp", "base"."comment" AS "comment", "base"."force" AS "force" FROM "workflow_transition_history" "base" WHERE "base"."hid" IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3); Array ( [:db_condition_placeholder_0] => 465 [:db_condition_placeholder_1] => 464 [:db_condition_placeholder_2] => 460 [:db_condition_placeholder_3] => 459 ) in main() (line 19 of index.php).
    
  • 🇨🇭Switzerland ayalon

    I have added a custom update hook in a custom module to fix it:

    use Drupal\Core\Field\BaseFieldDefinition;
    
    /**
     * Add force field to workflow_transition entity.
     */
    function my_module_update_9001() {
      $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
    
      // Create the field definition for the 'force' field
      $field_definition = BaseFieldDefinition::create('boolean')
        ->setLabel(t('Force transition'))
        ->setDescription(t('If this box is checked, the new state will be assigned even if workflow permissions disallow it.'))
        ->setDisplayOptions('form', [
          'type' => 'boolean_checkbox',
        ])
        ->setDisplayConfigurable('form', FALSE);
    
      // Install the new field definition
      $definition_update_manager->installFieldStorageDefinition('force', 'workflow_transition', 'workflow', $field_definition);
    }
    
  • 🇳🇱Netherlands johnv

    I noticed the error in #7 already.
    The field is now computed - it should not be saved.
    Please try 2.1.1

  • 🇳🇱Netherlands johnv

    You May need to rerun the most recent hook_update

  • 🇳🇱Netherlands johnv

    Please test v2.1.2 or v2.0.x-dev, run update.php, and report back.

  • @johnv, thank you for the update. Unfortunately the symptom is reproduced with version 2.1.2.

  • kubokura, can you try this fix: https://www.drupal.org/project/workflow/issues/3520853#comment-16225281 🐛 Extra Workflow fields don't work as of v1.8 Active

  • 🇳🇱Netherlands johnv

    This is now included in dev version 2.1.x

  • sboden, thank you for the information. I confirmed the symptom was reproduced with the patch against version 2.1.2 and with dev version 2.1.x.

  • Strange... I had it too, but it's fixed in the latest versions for me.

    Can you try:

    composer require 'drupal/workflow:2.1.x-dev@dev'
    

    and test again?

  • sboden, thank you for reply. Again I have confirmed the symptom is reproduced with dev version 2.1.x.

    vi composer.lock
    "drupal/workflow": "^1.5" -> "drupal/workflow": "^1.5 || ^2.0"
    composer require 'drupal/workflow:2.1.x-dev@dev'
    drush updb
    drush cr

  • Don't manually change your composer.lock file: nothing ever good comes from that, EVER.
    composer require 'drupal/workflow:2.1.x-dev@dev' properly updates composer.json and composer.lock file.

    I have 2 projects: one recent Drupal 11.2.3 and a Drupal 10.4.5 on which that workflow version works (the version of yesterday anyway, commit tag 41669fddb1b390a441e3516c261374dacd30617f). So if you want to try my exact current version do: composer require 'drupal/workflow:=2.1.x-dev#41669fddb1b390a441e3516c261374dacd30617f'

    Questions:
    a) Do you see any errors in watchdog after opening the workflow view: drush ws --extended
    b) Do you have an old database that you can retry with, one from before you had this problem. If so, reload and retest.
    c) When you make new workflow transitions now, do they show up properly? And what does watchdog show after creating a workflow transition.

  • 🇳🇱Netherlands johnv

    Sorry,
    I misunderstood #16's "I confirmed the symptom was reproduced" for "[..] the symptom was fixed"..

    I will also implement #8. Since for a short while the 'forced' field was not defined as computed.
    Apparently the workflow_update_8007() does ot work for your situation.

  • 🇳🇱Netherlands johnv

    The problem may also be that your Hook_update() number is 9001.
    That means that any hoop_update is provided by the module with a LOWER number, will NOT be implemented.
    Please make sure that you hook_update number reset. (I am not sure how to do that).

    • johnv committed 53b9e8c5 on 2.1.x
      Issue #3529085: Workflow history has disappeared after upgrading from 8....
  • 🇳🇱Netherlands johnv

    Please download newest dev version, make sure your hook_update number is correct, run update.php and test again.

  • To get and reset your hook_update number:

    # to get:
    drush sql-query "SELECT value FROM key_value WHERE collection='system.schema' AND name='workflow';"
    
    # reset: replace 8001 with the number you want to set it to.
    drush sql-query "UPDATE key_value SET value='i:8001;' WHERE collection='system.schema' AND name='workflow';"
  • johnv, sboden, thank you for your comments. The id of old database seems 8002. I reset to several ids (8007, 8003, 8009, 8011, 8001), and do drush updb, but I still have the problem.

    drush sql-query "SELECT value FROM key_value WHERE collection='system.schema' AND name='workflow';"
      i:8002;
    
    composer require 'drupal/workflow:2.1.x-dev@dev'
    composer show | grep workflow
      drupal/workflow                              dev-2.1.x 202e90e
    drush sql-query "UPDATE key_value SET value='i:nnnn;' WHERE collection='system.schema' AND name='workflow';"
    drush updb
    - when nnnn=8011
     [success] No pending updates.
    - when nnnn=8007, 8003
     ---------- ----------- --------------- ---------------------------------------
      Module     Update ID   Type            Description
     ---------- ----------- --------------- ---------------------------------------
      workflow   8009        hook_update_n   8009 - Updates existing configuration
                                             to match configuration schema.
      workflow   8011        hook_update_n   8011 - This will fix the Error
                                             'Mismatched entity and/or field
                                             definitions' on
                                             /admin/reports/status.
     ---------- ----------- --------------- ---------------------------------------
    - when nnnn=8009
     ---------- ----------- --------------- ---------------------------------------
      Module     Update ID   Type            Description
     ---------- ----------- --------------- ---------------------------------------
      workflow   8011        hook_update_n   8011 - This will fix the Error
                                             'Mismatched entity and/or field
                                             definitions' on
                                             /admin/reports/status.
     ---------- ----------- --------------- ---------------------------------------
    drush cr

    Regarding #20 questions;
    a)
    Q. Do you see any errors in watchdog after opening the workflow view: drush ws --extended
    A. No, I saw no errors in watchdog after opening the workflow view.
    b)
    Q. Do you have an old database that you can retry with, one from before you had this problem. If so, reload and retest.
    A. I have restored my Azure VM machine with workflow 8.x-1.7(old database), and tried 'drupal/workflow:=2.1.x-dev#41669fddb1b390a441e3516c261374dacd30617f', but I still have the problem.
    c)
    Q. When you make new workflow transitions now, do they show up properly? And what does watchdog show after creating a workflow transition.
    A. I have added a new workflow, added workflow tab on Basic Page, and created a new Basic Page, but workflow history does not show up. Watchdog show no error.

  • 🇳🇱Netherlands johnv

    OK, niow that you have added some new transitions, please check "workflow_transition_history" table.
    I guess all records have valid records.

    When saveing the transitions, there might be a mismatch between the 'target_id' and the 'value' of the Itemlist item. But that does not seem the case.
    So, the problem is in the reading of the table, and the translation from DB-column to WorkflowTransition values.

    The Workflow History page is served by WorkflowTransitionListController.php.
    Here, you find 2 options, hardcode toggled by $use_views_instead_of_list_builder = TRUE; :
    - the view is generated by a hardcode list - this is disabled by defalut, and it only there as a fallback and for testing.
    - the view is generated by a Views view display 'Workflow Entity Hitory'.

    Did you update/change the view? Please reset and see what happens, or, safer, remove and re-add a from/to State column, and upon success, the other one.
    If no success, you may set the toggle for testing.

  • johnv, thank you for sharing the key file name. I have compared WorkflowTransitionListController.php of 2.1.x-dev with the one of 8.x-1.7.
    And I have changed to the same $args array as 8.x-1.7, and it works for me. Could you review the code below?

    The code is from https://git.drupalcode.org/project/workflow/-/blob/2.1.x/src/Controller/WorkflowTransitionListController.php?ref_type=heads
        /*
         * Step 2: generate the Transition History List.
         */
        $use_views_instead_of_list_builder = TRUE;
        $view = NULL;
        if ($use_views_instead_of_list_builder == TRUE
        && $this->moduleHandler->moduleExists('views')) {
          $view = Views::getView('workflow_entity_history');
          if ($view?->storage?->status()) {
            // Add the history list from configured Views display.
    L.121
    //        $args = [
    //          $entity->getEntityTypeId(),
    //          $entity->id(),
    //        ];
            $args = [$entity->id()];  // replaced
            $view->setArguments($args);
            $view->setDisplay('workflow_history_tab');
            $view->preExecute();
            $view->execute();
            $form['table'] = $view->buildRenderable();
          }
        }
    
  • 🇳🇱Netherlands johnv

    Did you update/change the Views display 'workflow_entity_history'? Please reset and see what happens.

  • >Did you update/change the Views display 'workflow_entity_history'?
    johnv, could you let me know how I can operate this?
    Click the Update workflow button at the workflow tab of a content (/node/nnnn/workflow)?
    Or just click the Save button at /admin/structure/views/view/workflow_entity_history?
    Or else?

  • 🇳🇱Netherlands johnv

    The simplest way in admin UI to restore the original Views display would be to delete the View and import it again.
    - Go to /admin/structure/views/view/workflow_entity_history and choose 'Delete view'
    - Goto /admin/config/development/configuration/single/import and select the configuration type View.
    - Copy and paste the content of the file https://git.drupalcode.org/project/workflow/-/blob/2.1.x/config/optional...

    Backup your own Views.yml first and then check the differences.
    - Goto admin/config/development/configuration/single/export

    Or compare the current view with the settings in attached screendump.
    I guess the problem is with the new arguments.

  • 🇳🇱Netherlands johnv

    Release workflow 2.1.7 has been created.

  • johnv, thank you for the detailed instructions. It works for me.

    And the following steps also works for me. Thank you for attaching the PNG file, too.

    composer require 'drupal/workflow:2.1.x-dev@dev'
    composer show | grep workflow
      drupal/workflow  dev-2.1.x 2cc540d
    drush updb
    drush cr
    Go to /admin/structure/views/view/workflow_entity_history, add Entity type and Field name at Contextual filters, and rearrange items Entity type, Entity ID(existing), Field name as the PNG shows.
  • 🇳🇱Netherlands johnv

    Nice,
    I updated the issue summary with the findings and changed it into a Documentation topic. Leaving it open for other to find it quickly.

Production build 0.71.5 2024