|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Content\Query\CriterionHandler; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
|
12
|
|
|
use Doctrine\DBAL\Query\QueryBuilder; |
|
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Query\CriteriaConverter; |
|
14
|
|
|
use RuntimeException; |
|
15
|
|
|
|
|
16
|
|
|
class UserMetadata extends Base |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
public function accept(Criterion $criterion): bool |
|
22
|
|
|
{ |
|
23
|
|
|
return $criterion instanceof Criterion\SectionId; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritdoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function handle(CriteriaConverter $converter, QueryBuilder $query, Criterion $criterion): string |
|
30
|
|
|
{ |
|
31
|
|
|
$expr = $query->expr(); |
|
|
|
|
|
|
32
|
|
|
/*return $expr->in( |
|
33
|
|
|
'content.section_id', |
|
34
|
|
|
$query->createNamedParameter((array)$criterion->value, Connection::PARAM_INT_ARRAY) |
|
35
|
|
|
);*/ |
|
36
|
|
|
|
|
37
|
|
|
/* @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\UserMetadata $criterion */ |
|
38
|
|
|
switch ($criterion->target) { |
|
39
|
|
|
|
|
40
|
|
|
case Criterion\UserMetadata::MODIFIER: |
|
41
|
|
|
$this->addInnerJoinIfNeeded( |
|
42
|
|
|
$query, |
|
43
|
|
|
'content', |
|
44
|
|
|
'ezcontentobject_version', |
|
45
|
|
|
'version', |
|
46
|
|
|
'version.contentobject_id = content.id AND version.version = content.current_version' |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
return $this->operateInt($query, 'version.creator_id', $criterion); |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
// @TODO Needed for permissions |
|
53
|
|
|
/*case Criterion\UserMetadata::GROUP: |
|
54
|
|
|
$subSelect = $query->subSelect(); |
|
55
|
|
|
$subSelect |
|
56
|
|
|
->select( |
|
57
|
|
|
$this->dbHandler->quoteColumn('contentobject_id', 't1') |
|
58
|
|
|
)->from( |
|
59
|
|
|
$query->alias( |
|
60
|
|
|
$this->dbHandler->quoteTable('ezcontentobject_tree'), |
|
61
|
|
|
't1' |
|
62
|
|
|
) |
|
63
|
|
|
)->innerJoin( |
|
64
|
|
|
$query->alias( |
|
65
|
|
|
$this->dbHandler->quoteTable('ezcontentobject_tree'), |
|
66
|
|
|
't2' |
|
67
|
|
|
), |
|
68
|
|
|
$query->expr->like( |
|
69
|
|
|
't1.path_string', |
|
70
|
|
|
$query->expr->concat( |
|
71
|
|
|
't2.path_string', |
|
72
|
|
|
$query->bindValue('%') |
|
73
|
|
|
) |
|
74
|
|
|
) |
|
75
|
|
|
)->where( |
|
76
|
|
|
$query->expr->in( |
|
77
|
|
|
$this->dbHandler->quoteColumn('contentobject_id', 't2'), |
|
78
|
|
|
$criterion->value |
|
79
|
|
|
) |
|
80
|
|
|
); |
|
81
|
|
|
|
|
82
|
|
|
return $query->expr->in( |
|
83
|
|
|
$this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), |
|
84
|
|
|
$subSelect |
|
85
|
|
|
);*/ |
|
86
|
|
|
|
|
87
|
|
|
case Criterion\UserMetadata::OWNER: |
|
88
|
|
|
return $this->operateInt($query, 'content.owner_id', $criterion); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
throw new RuntimeException("Invalid target criterion encountered:'" . $criterion->target . "'"); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.