joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

Can not save transition of workflow for extension without workflow plugins #44447

Open softarius opened 3 days ago

softarius commented 3 days ago

Steps to reproduce the issue

Go index.php?option=com_workflow&view=workflows&extension=com_contact Create and save new Workflow Click Transitions and create new transitions Type name of transition and try click Save or Save & Close

Expected result

Saved transition

Actual result

Save failed with the following error ... "options" .. "cms_workflow_transitions" .. NOT NULL DETAIL

System information (as much as possible)

Joomla 5.2.1 PHP 8.1 Postgresql

Additional comments

I fixed it just

ALTER TABLE #__workflow_transitions
  ALTER COLUMN options SET DEFAULT '{}';
richard67 commented 3 days ago

I fixed it just

ALTER TABLE #__workflow_transitions ALTER COLUMN options SET DEFAULT '{}';

@softarius This will casue an SQL error on MySQL 8 as on MySQL 8, columns with TEXT data types (TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT) are not allowed to have a default value. See https://dev.mysql.com/doc/refman/8.0/en/blob.html :

BLOB and TEXT columns cannot have DEFAULT values.

See also PR #27937 .

P.S.: I know, your issue and your fix are for PostgreSQL. But we want to have consistent data structures on all kinds of databases so data can be ported, that's why we also don't use default values on TEXT columns in PostgreSQL anymore.

softarius commented 2 days ago

Well, whath about this patch?

diff --git "a/www/administrator/components/com_workflow/src/Model/TransitionModel.php" "b/www/administrator/components/com_workflow/src/Model/TransitionModel.php"
index a1db4c04..d3ce79ef 100644
--- "a/www/administrator/components/com_workflow/src/Model/TransitionModel.php"
+++ "b/www/administrator/components/com_workflow/src/Model/TransitionModel.php"
@@ -177,7 +177,9 @@ class TransitionModel extends AdminModel

             $data['published'] = 0;
         }
-
+        if (!key_exists('options', $data) || !$data['options']) {
+            $data['options'] = '{}';
+        }
         return parent::save($data);
     }
richard67 commented 2 days ago

@bembelimen Could you have a look on this issue and check the fix proposed in the previous comment?