blob: 5cbf21d56d42a99cbfe86212f3695698867d3c65 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<?php
declare(strict_types=1);
namespace Drupal\node\Plugin\views;
/**
* Checks for nodes that a user posted or created a revision on.
*/
trait UidRevisionTrait {
/**
* Checks for nodes that a user posted or created a revision on.
*
* @param array $uids
* A list of user ids.
* @param int $group
* See \Drupal\views\Plugin\views\query\Sql::addWhereExpression() $group.
*/
public function uidRevisionQuery(array $uids, int $group = 0): void {
$this->ensureMyTable();
// As per https://www.php.net/manual/en/pdo.prepare.php "you cannot use a
// named parameter marker of the same name more than once in a prepared
// statement".
$placeholder_1 = $this->placeholder() . '[]';
$placeholder_2 = $this->placeholder() . '[]';
$args = array_values($uids);
$this->query->addWhereExpression($group, "$this->tableAlias.uid IN ($placeholder_1) OR
EXISTS (SELECT 1 FROM {node_revision} nr WHERE nr.revision_uid IN ($placeholder_2) AND nr.nid = $this->tableAlias.nid)", [
$placeholder_1 => $args,
$placeholder_2 => $args,
]);
}
}
|