Skip to content
Permalink
Browse files

EZP-29796: Legacy transaction handling issues (ezsystems#27)

* EZP-28681: Legacy transaction handling issues
1. Status change during autosave
  • Loading branch information...
glye committed Feb 15, 2019
1 parent 16d80c6 commit 733aa9e239c063b9c7209ebafda1004e12321904
Showing with 12 additions and 4 deletions.
  1. +12 −4 classes/ezjscserverfunctionsautosave.php
@@ -65,9 +65,14 @@ static public function saveDraft( $args )
)
);
}
$contentObject = eZContentObject::fetch( (int)$args[0] );
$db = eZDB::instance();
$db->begin();
$contentObject = eZContentObject::fetchForUpdate( (int)$args[0] );
if ( !$contentObject instanceof eZContentObject )
{
$db->commit();
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -79,6 +84,7 @@ static public function saveDraft( $args )
if ( $contentObject->attribute( 'status' ) == eZContentObject::STATUS_ARCHIVED )
{
$db->commit();
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -90,9 +96,10 @@ static public function saveDraft( $args )
);
}
$version = $contentObject->version( (int)$args[1] );
$version = eZContentObjectVersion::fetchVersionForUpdate( (int)$args[1], $contentObject->attribute( 'id' ) );
if ( !$version instanceof eZContentObjectVersion )
{
$db->commit();
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -107,6 +114,7 @@ static public function saveDraft( $args )
if ( $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_DRAFT
&& $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_INTERNAL_DRAFT )
{
$db->commit();
throw new RuntimeException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -120,6 +128,7 @@ static public function saveDraft( $args )
}
if ( $version->attribute( 'creator_id' ) != eZUser::currentUserID() )
{
$db->commit();
throw new RuntimeException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -132,6 +141,7 @@ static public function saveDraft( $args )
$language = eZContentLanguage::fetchByLocale( $editLanguage );
if ( !$language instanceof eZContentLanguage )
{
$db->commit();
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezautosave/autosave',
@@ -201,8 +211,6 @@ static public function saveDraft( $args )
}
}
$db = eZDB::instance();
$db->begin();
$version->store();
$contentObject->storeInput( $contentObjectAttributes, $attributesToStore );
$contentObject->setName(

0 comments on commit 733aa9e

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.