Fix list_order and update_order not bumped when updating a temporarily saved document (2.1.5 regression)

https://xetown.com/questions/1814863
This commit is contained in:
Kijin Sung 2024-03-19 22:45:44 +09:00
parent c996ab1259
commit 7c8e76b727
2 changed files with 15 additions and 18 deletions

View file

@ -178,14 +178,8 @@ class BoardController extends Board
} }
} }
// if document status is temp // Additional protections for published (non-TEMP) documents
if($oDocument->get('status') == DocumentModel::getConfigStatus('temp')) if($oDocument->get('status') !== DocumentModel::getConfigStatus('temp'))
{
// Update list order, date
$obj->last_update = $obj->regdate = date('YmdHis');
$obj->update_order = $obj->list_order = (getNextSequence() * -1);
}
else
{ {
// Protect document by comment // Protect document by comment
if($this->module_info->protect_content == 'Y' || $this->module_info->protect_update_content == 'Y') if($this->module_info->protect_content == 'Y' || $this->module_info->protect_update_content == 'Y')

View file

@ -997,13 +997,25 @@ class DocumentController extends Document
// can modify regdate only manager // can modify regdate only manager
$grant = Context::get('grant'); $grant = Context::get('grant');
if(!$grant->manager) if(!$grant->manager && !$manual_updated)
{ {
unset($obj->regdate); unset($obj->regdate);
unset($obj->last_update); unset($obj->last_update);
unset($obj->list_order); unset($obj->list_order);
} }
// Set default values for regdate, list_order, and update_order.
if ($is_publish)
{
$obj->regdate = date('YmdHis');
$obj->list_order = getNextSequence() * -1;
$obj->update_order = $obj->list_order;
}
else
{
$obj->update_order = getNextSequence() * -1;
}
// Serialize the $extra_vars // Serialize the $extra_vars
if (isset($obj->extra_vars) && !is_string($obj->extra_vars)) if (isset($obj->extra_vars) && !is_string($obj->extra_vars))
{ {
@ -1036,9 +1048,6 @@ class DocumentController extends Document
} }
} }
// Change the update order
$obj->update_order = getNextSequence() * -1;
// Hash the password if it exists // Hash the password if it exists
if($obj->password) if($obj->password)
{ {
@ -1124,12 +1133,6 @@ class DocumentController extends Document
} }
} }
// if temporary document, regdate is now setting
if ($source_obj->get('status') == $this->getConfigStatus('temp'))
{
$obj->regdate = date('YmdHis');
}
// Insert data into the DB // Insert data into the DB
$output = executeQuery('document.updateDocument', $obj); $output = executeQuery('document.updateDocument', $obj);
if(!$output->toBool()) if(!$output->toBool())