In #1801726: EntityFieldQuery v2 AddMetaData() was removed from EFQ.

In #1801304: Add Entity reference field we need to be able to add the Selection handler to the EFQ object, as later on in hook_query_TAG_alter() we want to let the Selection handler alter the sqlQuery for entity-access:

<?php
/**
* Implements hook_query_TAG_alter().
*/
function entity_reference_query_entity_reference_alter(AlterableInterface $query) {
 
$handler = $query->getMetadata('entity_reference_selection_handler');
 
$handler->entityFieldQueryAlter($query);
}
?>

Here's a gist with a clearer flow.

chx via IRC asked to file an issue.

Files: 
CommentFileSizeAuthor
#8 1828408-efq-tag-7.patch5.13 KBAmitaibu
PASSED: [[SimpleTest]]: [MySQL] 47,748 pass(es).
[ View ]
#8 interdiff-7.txt1.96 KBAmitaibu
#6 1828408-efq-tag-6.patch5.09 KBAmitaibu
PASSED: [[SimpleTest]]: [MySQL] 47,593 pass(es).
[ View ]
#6 interdiff.txt2.68 KBAmitaibu
#4 1828408-efq-tag-4.patch3.11 KBAmitaibu
PASSED: [[SimpleTest]]: [MySQL] 47,633 pass(es).
[ View ]
#3 1828408-efq-tag-3.patch2.19 KBAmitaibu
PASSED: [[SimpleTest]]: [MySQL] 47,589 pass(es).
[ View ]

Comments

Title:Re-add AddMetaData to EFQRe-add addTag() and AddMetaData() to EFQ

Better title, to indicate addTag() is also required as we want to act only on "entity_reference" related queries.

I hoped you will actually file a patch :) I will see what i can do.

Status:Active» Needs work
StatusFileSize
new2.19 KB
PASSED: [[SimpleTest]]: [MySQL] 47,589 pass(es).
[ View ]

Very naive implementation. addMetadata seems to work, but addTag() not. Gonna dive a bit more into the code..

Status:Needs work» Needs review
StatusFileSize
new3.11 KB
PASSED: [[SimpleTest]]: [MySQL] 47,633 pass(es).
[ View ]

Am I in the right direction? :)

That looks quite good. It seems you are not adding metadata yet, it seems. And, do you think you could write a test for this? Perhaps flip a global in a field_test hook (because that module is already on) ?

StatusFileSize
new2.68 KB
new5.09 KB
PASSED: [[SimpleTest]]: [MySQL] 47,593 pass(es).
[ View ]

> do you think you could write a test for this?

Of course, that was the plan :) Patch with test.

Status:Needs review» Reviewed & tested by the community

Looks really good. Easy to see, test is good as well, works, same implementation as Select.php. => RTBC

One doc nitpick:

core/lib/Drupal/Core/Database/Query/Select.php has:

  /* Implementations of Drupal\Core\Database\Query\AlterableInterface. */
  public function addTag($tag) {

instead of:

+++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.phpundefined
@@ -239,4 +239,48 @@ public function tableSort(&$headers) {
+  /**
+   * Implements Drupal\Core\Entity\Query\QueryInterface::addTag().
+   */
+  public function addTag($tag) {

for each of those. I think it is nicer to know this is the implementation of the AlterableInterface than of the QueryInterface and it should be consistent.

StatusFileSize
new1.96 KB
new5.13 KB
PASSED: [[SimpleTest]]: [MySQL] 47,748 pass(es).
[ View ]

Addressing #7 -- @Fabianx, that's what you meant, right?

Status:Reviewed & tested by the community» Needs work

The last submitted patch, 1828408-efq-tag-7.patch, failed testing.

Status:Needs work» Needs review

Status:Needs review» Reviewed & tested by the community

Seems good.

Yup, #8: That was what I meant.

+1 for RTBC

Status:Reviewed & tested by the community» Fixed

Committed and pushed to 8.x. Thanks!

Status:Fixed» Closed (fixed)

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