Skip to content

Commit

Permalink
Merge branch '6.13' into 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Oct 3, 2018
2 parents cdc02d1 + f5fae0a commit dc445ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Expand Up @@ -269,7 +269,7 @@
{% for contentId in field.value.destinationContentIds if parameters.available[contentId] %}
{{ fos_httpcache_tag('relation-' ~ contentId) }}
<li>
{{ render( controller( "ez_content:viewAction", {'contentId': contentId, 'viewType': 'embed', 'noLayout': 1} ) ) }}
{{ render( controller( "ez_content:viewAction", {'contentId': contentId, 'viewType': 'embed', 'layout': false} ) ) }}
</li>
{% endfor %}
</ul>
Expand Down Expand Up @@ -334,7 +334,7 @@
{% if parameters.showInfo is defined and not parameters.showInfo %}
{% set showInfo = false %}
{% endif %}

{% set draggable = defaultDraggable %}
{% if parameters.draggable is defined and not parameters.draggable %}
{% set draggable = 'false' %}
Expand Down Expand Up @@ -435,7 +435,7 @@
{% if not ez_is_field_empty( content, field ) and parameters.available %}
{{ fos_httpcache_tag('relation-' ~ field.value.destinationContentId) }}
<div {{ block( 'field_attributes' ) }}>
{{ render( controller( "ez_content:viewAction", {'contentId': field.value.destinationContentId, 'viewType': 'text_linked', 'noLayout': 1} ) ) }}
{{ render( controller( "ez_content:viewAction", {'contentId': field.value.destinationContentId, 'viewType': 'text_linked', 'layout': false} ) ) }}
</div>
{% endif %}
{% endspaceless %}
Expand Down
Expand Up @@ -324,7 +324,7 @@
<div class="ez-fielddefinition-setting-name">{{ 'fielddefinition.selection-root.label'|trans|desc("Selection root:")}}</div>
<div class="ez-fielddefinition-setting-value">
{% if rootLocationId %}
{{ render( controller( "ez_content:viewAction", {'locationId': rootLocationId, 'viewType': 'line'} ), {'strategy': 'esi'}) }}
{{ render( controller( "ez_content:viewAction", {'locationId': rootLocationId, 'viewType': 'line', 'layout': false} ), {'strategy': 'esi'}) }}
{% else %}
<em>{{ 'fielddefinition.selection-root.undefined'|trans|desc("No defined root")}}</em>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/API/Repository/ContentService.php
Expand Up @@ -283,7 +283,7 @@ public function publishVersion(VersionInfo $versionInfo);
* Removes the given version.
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
* published state or is a last version of the Content
* published state or is a last version of Content in non draft state
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
*
* @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
Expand Down
10 changes: 6 additions & 4 deletions eZ/Publish/API/Repository/Tests/ContentServiceTest.php
Expand Up @@ -3086,12 +3086,12 @@ public function testDeleteVersionThrowsBadStateExceptionOnPublishedVersion()
* Test for the deleteVersion() method.
*
* @see \eZ\Publish\API\Repository\ContentService::deleteVersion()
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
*/
public function testDeleteVersionThrowsBadStateExceptionOnLastVersion()
public function testDeleteVersionWorksIfOnlyVersionIsDraft()
{
$repository = $this->getRepository();

Expand All @@ -3100,9 +3100,11 @@ public function testDeleteVersionThrowsBadStateExceptionOnLastVersion()
/* BEGIN: Use Case */
$draft = $this->createContentDraftVersion1();

// This call will fail with a "BadStateException", because the Content
// version is the last version of the Content.
$contentService->deleteVersion($draft->getVersionInfo());

// This call will fail with a "NotFound", because we allow to delete content if remaining version is draft.
// Can normally only happen if there where always only a draft to begin with, simplifies UI edit API usage.
$contentService->loadContent($draft->id);
/* END: Use Case */
}

Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Repository/ContentService.php
Expand Up @@ -1565,7 +1565,7 @@ protected function getUnixTimestamp()
* Removes the given version.
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
* published state or is the last version of the Content
* published state or is a last version of Content in non draft state
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
*
* @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
Expand Down Expand Up @@ -1593,7 +1593,7 @@ public function deleteVersion(APIVersionInfo $versionInfo)
2
);

if (count($versionList) === 1) {
if (count($versionList) === 1 && !$versionInfo->isDraft()) {
throw new BadStateException(
'$versionInfo',
'Version is the last version of the Content and can not be removed'
Expand Down

0 comments on commit dc445ef

Please sign in to comment.