Problem/Motivation
In #2498919: Node::isPublished() and Node::getOwnerId() are expensive, it was identified that Node::isPublished is slow, so a cache was introduced through getEntityKey. The issue introduced the following change to isPublished:
+++ b/core/modules/node/src/Entity/Node.php
@@ -258,7 +267,7 @@ public function setSticky($sticky) {
- return (bool) $this->get('status')->value;
+ return (bool) $this->getEntityKey('status');
and our current implementation is:
public function isPublished() {
$key = $this->getEntityType()->getKey('published');
return (bool) $this->get($key)->value;
}
Proposed resolution
Make use of getEntityKey in EntityPublishedTrait
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
sam152 commentedSeeing if anything breaks with this change. This is possibly impacted by a bug being fixed in #2961986: The ContentEntityBase entity key cache is purged incorrectly when two keys exist for one field..
Comment #5
sam152 commentedApplying this with the blocker seems to fix a few tests. Testing with the blocker applied.
Edit: Yep! The blocker was the only thing preventing us from using this in EntityPublishedTrait.
Comment #6
tstoecklerLooks great, thanks! Can be RTBC once the other is in.
Comment #7
sam152 commentedBlocker is in.
Comment #8
amietpatial commented@Sam152 I applied your patch and it works fine
Comment #9
tstoecklerPerfect, thank you!
Comment #10
alexpott@amietpatial thanks for testing the patch but images of patches being applied don't tell us anything that the testbot does not already tell us.
Comment #11
alexpottCommitted 52fdfaa and pushed to 8.6.x. Thanks!