Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29899: Content loading can end up loading wrong version under concurrency #2502

Merged
merged 4 commits into from
Dec 20, 2018

Conversation

andrerom
Copy link
Contributor

@andrerom andrerom commented Dec 14, 2018

Question Answer
JIRA issue EZP-29899
Bug yes
Target version 5.4 and up
BC breaks no
Tests pass yes
Doc needed no

Under concurrency it's possible that current version number we get in content info
is out of date by the time we ask for full content object. So change
SPI to allow loading current version number directly.

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.
  • On MERGE remember to adapt 6.13 and up with:
diff --git a/eZ/Publish/Core/Persistence/Cache/ContentHandler.php b/eZ/Publish/Core/Persistence/Cache/ContentHandler.php
index eccd98924d..f28bdc3c41 100644
--- a/eZ/Publish/Core/Persistence/Cache/ContentHandler.php
+++ b/eZ/Publish/Core/Persistence/Cache/ContentHandler.php
@@ -368,6 +373,7 @@ class ContentHandler extends AbstractHandler implements ContentHandlerInterface
             $languageCode
         );
         $this->cache->clear('content', $contentId, $versionNo);
+        $this->cache->clear('content', $contentId, self::PUBLISHED_VERSION);
         $this->cache->clear('content', 'info', $contentId, 'versioninfo', $versionNo);
 
         return $content;
diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php
index e38d78d0f4..92575b2ee2 100644
--- a/eZ/Publish/Core/Repository/ContentService.php
+++ b/eZ/Publish/Core/Repository/ContentService.php
@@ -274,8 +274,3 @@ class ContentService implements ContentServiceInterface
         }
-
-         // As we have content info we can avoid that current version is looked up using spi in loadContent() if not set
-         if ($versionNo === null) {
-             $versionNo = $contentInfo->currentVersionNo;
-         }

        return $this->loadContent(

@andrerom andrerom changed the base branch from master to 6.7 December 14, 2018 15:22
…currency

Under concurrency it's possible that current version number we get in content info
is out of date by the time we ask for full content object. So change
SPI to allow loading current version number directly.
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes perfect sense, some nitpicks:


return $statement->fetchAll(\PDO::FETCH_ASSOC);
return $list[0];*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code detected 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php Outdated Show resolved Hide resolved
eZ/Publish/SPI/Persistence/Content/Handler.php Outdated Show resolved Hide resolved
Copy link

@m-tyrala m-tyrala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity tests passed

@andrerom andrerom merged commit 9d44b53 into 6.7 Dec 20, 2018
@andrerom andrerom deleted the EZP-29899 branch December 20, 2018 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants