Skip to content

Commit

Permalink
Take workflow extension into account when setting a default
Browse files Browse the repository at this point in the history
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
  • Loading branch information
roland-d committed Jan 1, 2022
1 parent 5694e30 commit 693b984
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Expand Up @@ -297,7 +297,13 @@ public function setDefault($pk, $value = 1)
if ($value)
{
// Unset other default item
if ($table->load(array('default' => '1')))
if ($table->load(
[
'default' => '1',
'extension' => $table->get('extension')
]
)
)
{
$table->default = 0;
$table->modified = $date;
Expand Down
14 changes: 10 additions & 4 deletions administrator/components/com_workflow/src/Table/WorkflowTable.php
Expand Up @@ -144,7 +144,7 @@ public function check()
}
else
{
$db = $this->getDbo();
$db = $this->getDbo();
$query = $db->getQuery(true);

$query
Expand Down Expand Up @@ -192,7 +192,7 @@ public function store($updateNulls = true)
{
// Existing item
$this->modified_by = $user->id;
$this->modified = $date->toSql();
$this->modified = $date->toSql();
}
else
{
Expand All @@ -219,10 +219,16 @@ public function store($updateNulls = true)
$this->modified_by = $this->created_by;
}

if ($this->default == '1')
if ((int) $this->default === 1)
{
// Verify that the default is unique for this workflow
if ($table->load(array('default' => '1')))
if ($table->load(
[
'default' => '1',
'extension' => $this->extension
]
)
)
{
$table->default = 0;
$table->store();
Expand Down

0 comments on commit 693b984

Please sign in to comment.