Node grants gets its operation from the query's "op" metadata. Entity API's query access alters hardcode the operation to view. Let's fix this by mimicking the node grants system's way of retrieving an operation.

Comments

kristiaanvandeneynde created an issue. See original summary.

kristiaanvandeneynde’s picture

Status: Active » Needs review
StatusFileSize
new1.11 KB

Seems like the views query does not support getMetadata (but rather $options) so there's no operation to retrieve there.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Pretty sure the = instead of == is deliberate here. LGTM.

kristiaanvandeneynde’s picture

It sure is :D

berdir’s picture

+++ b/src/QueryAccess/EntityQueryAlter.php
@@ -103,7 +103,10 @@ class EntityQueryAlter implements ContainerInjectionInterface {
     $query_access = $this->entityTypeManager->getHandler($entity_type_id, 'query_access');
-    $conditions = $query_access->getConditions('view');
...
+      $operation = 'view';
+    }
...
     if ($conditions->isAlwaysFalse()) {
       $query->where('1 = 0');

Nitpick, but can't we just write this as $query_access->getConditions($query->getMetaData('op') ?: 'view');

Avoids the quite tricky conditional inverted if condition and we don't need operation afterwards.

kristiaanvandeneynde’s picture

Sure, that would work :)

sanjayk’s picture

Assigned: Unassigned » sanjayk
Status: Reviewed & tested by the community » Needs work

Working on coding standard issues.

kristiaanvandeneynde’s picture

Assigned: sanjayk » Unassigned
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new783 bytes
new26.83 KB

Not sure what coding standards issues can be worked on in a 1-line patch (as per #5)

kristiaanvandeneynde’s picture

StatusFileSize
new691 bytes

Ugh, first time using the awesome drupalorg-cli for generating patches and got the wrong one :)

sanjayk’s picture

StatusFileSize
new18.96 KB

Fixed coding standard issues. Few are still left which is based on ie:Doc comment etc.

sanjayk’s picture

StatusFileSize
new12.97 KB

And also patch apply successfully.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Committed. And if we ever need it as a variable, we could still do the same assigned to the variable instead.

tormi’s picture

@sanjayk, the issue etiquette applies here, could you please follow it?

sanjayk’s picture

@tormi sure I will follow thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.