Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
310
Merge Requests
310
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
ee820da6
Commit
ee820da6
authored
Jun 26, 2014
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2183417
by kgoel, alimac: In Sql Rename Views properties to core standards.
parent
2e3893a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
41 deletions
+41
-41
core/modules/views/src/Plugin/views/query/QueryPluginBase.php
.../modules/views/src/Plugin/views/query/QueryPluginBase.php
+1
-1
core/modules/views/src/Plugin/views/query/Sql.php
core/modules/views/src/Plugin/views/query/Sql.php
+40
-40
No files found.
core/modules/views/src/Plugin/views/query/QueryPluginBase.php
View file @
ee820da6
...
...
@@ -175,7 +175,7 @@ public function setWhereGroup($type = 'AND', $group = NULL, $where = 'where') {
* Either 'AND' or 'OR'
*/
public
function
setGroupOperator
(
$type
=
'AND'
)
{
$this
->
group
_o
perator
=
strtoupper
(
$type
);
$this
->
group
O
perator
=
strtoupper
(
$type
);
}
/**
...
...
core/modules/views/src/Plugin/views/query/Sql.php
View file @
ee820da6
...
...
@@ -32,7 +32,7 @@ class Sql extends QueryPluginBase {
/**
* A list of tables in the order they should be added, keyed by alias.
*/
var
$table_q
ueue
=
array
();
protected
$tableQ
ueue
=
array
();
/**
* Holds an array of tables and counts added so that we can create aliases
...
...
@@ -61,7 +61,7 @@ class Sql extends QueryPluginBase {
* The default operator to use when connecting the WHERE groups. May be
* AND or OR.
*/
var
$group_o
perator
=
'AND'
;
protected
$groupO
perator
=
'AND'
;
/**
* A simple array of order by clauses.
...
...
@@ -84,17 +84,17 @@ class Sql extends QueryPluginBase {
*/
var
$distinct
=
FALSE
;
var
$has_a
ggregate
=
FALSE
;
protected
$hasA
ggregate
=
FALSE
;
/**
* Should this query be optimized for counts, for example no sorts.
*/
var
$get_count_o
ptimized
=
NULL
;
protected
$getCountO
ptimized
=
NULL
;
/**
* An array mapping table aliases and field names to field aliases.
*/
var
$field_a
liases
=
array
();
protected
$fieldA
liases
=
array
();
/**
* Query tags which will be passed over to the dbtng query object.
...
...
@@ -106,7 +106,7 @@ class Sql extends QueryPluginBase {
*
* @var bool
*/
var
$no_d
istinct
;
protected
$noD
istinct
;
/**
* Overrides \Drupal\views\Plugin\views\PluginBase::init().
...
...
@@ -124,7 +124,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
);
// init the table queue with our primary table.
$this
->
table
_q
ueue
[
$base_table
]
=
array
(
$this
->
table
Q
ueue
[
$base_table
]
=
array
(
'alias'
=>
$base_table
,
'table'
=>
$base_table
,
'relationship'
=>
$base_table
,
...
...
@@ -152,7 +152,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
* Should the view by distincted.
*/
protected
function
setDistinct
(
$value
=
TRUE
)
{
if
(
!
(
isset
(
$this
->
no
_d
istinct
)
&&
$value
))
{
if
(
!
(
isset
(
$this
->
no
D
istinct
)
&&
$value
))
{
$this
->
distinct
=
$value
;
}
}
...
...
@@ -297,7 +297,7 @@ public function addRelationship($alias, JoinPluginBase $join, $base, $link_point
// Add the table directly to the queue to avoid accidentally marking
// it.
$this
->
table
_q
ueue
[
$alias
]
=
array
(
$this
->
table
Q
ueue
[
$alias
]
=
array
(
'table'
=>
$join
->
table
,
'num'
=>
1
,
'alias'
=>
$alias
,
...
...
@@ -390,7 +390,7 @@ public function addTable($table, $relationship = NULL, JoinPluginBase $join = NU
*/
public
function
queueTable
(
$table
,
$relationship
=
NULL
,
JoinPluginBase
$join
=
NULL
,
$alias
=
NULL
)
{
// If the alias is set, make sure it doesn't already exist.
if
(
isset
(
$this
->
table
_q
ueue
[
$alias
]))
{
if
(
isset
(
$this
->
table
Q
ueue
[
$alias
]))
{
return
$alias
;
}
...
...
@@ -413,7 +413,7 @@ public function queueTable($table, $relationship = NULL, JoinPluginBase $join =
// Check this again to make sure we don't blow up existing aliases for already
// adjusted joins.
if
(
isset
(
$this
->
table
_q
ueue
[
$alias
]))
{
if
(
isset
(
$this
->
table
Q
ueue
[
$alias
]))
{
return
$alias
;
}
...
...
@@ -440,7 +440,7 @@ public function queueTable($table, $relationship = NULL, JoinPluginBase $join =
$join
=
$this
->
adjustJoin
(
$join
,
$relationship
);
}
$this
->
table
_q
ueue
[
$alias
]
=
array
(
$this
->
table
Q
ueue
[
$alias
]
=
array
(
'table'
=>
$table
,
'num'
=>
$this
->
tables
[
$relationship
][
$table
][
'count'
],
'alias'
=>
$alias
,
...
...
@@ -547,12 +547,12 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join =
// scan through the table queue to see if a matching join and
// relationship exists. If so, use it instead of this join.
// TODO: Scanning through $this->table
_q
ueue results in an
// TODO: Scanning through $this->table
Q
ueue results in an
// O(N^2) algorithm, and this code runs every time the view is
// instantiated (Views 2 does not currently cache queries).
// There are a couple possible "improvements" but we should do
// some performance testing before picking one.
foreach
(
$this
->
table
_q
ueue
as
$queued_table
)
{
foreach
(
$this
->
table
Q
ueue
as
$queued_table
)
{
// In PHP 4 and 5, the == operation returns TRUE for two objects
// if they are instances of the same class and have the same
// attributes and values.
...
...
@@ -657,8 +657,8 @@ protected function adjustJoin($join, $relationship) {
$join
->
leftTable
=
$this
->
tables
[
$relationship
][
$join
->
leftTable
][
'alias'
];
}
// But if we're already looking at an alias, use that instead.
elseif
(
isset
(
$this
->
table
_q
ueue
[
$relationship
][
'alias'
]))
{
$join
->
leftTable
=
$this
->
table
_q
ueue
[
$relationship
][
'alias'
];
elseif
(
isset
(
$this
->
table
Q
ueue
[
$relationship
][
'alias'
]))
{
$join
->
leftTable
=
$this
->
table
Q
ueue
[
$relationship
][
'alias'
];
}
}
...
...
@@ -680,8 +680,8 @@ protected function adjustJoin($join, $relationship) {
public
function
getJoinData
(
$table
,
$base_table
)
{
// Check to see if we're linking to a known alias. If so, get the real
// table's data instead.
if
(
!
empty
(
$this
->
table
_q
ueue
[
$table
]))
{
$table
=
$this
->
table
_q
ueue
[
$table
][
'table'
];
if
(
!
empty
(
$this
->
table
Q
ueue
[
$table
]))
{
$table
=
$this
->
table
Q
ueue
[
$table
][
'table'
];
}
return
HandlerBase
::
getTableJoin
(
$table
,
$base_table
);
}
...
...
@@ -693,15 +693,15 @@ public function getJoinData($table, $base_table) {
* ensureTable().
*/
public
function
getTableInfo
(
$table
)
{
if
(
!
empty
(
$this
->
table
_q
ueue
[
$table
]))
{
return
$this
->
table
_q
ueue
[
$table
];
if
(
!
empty
(
$this
->
table
Q
ueue
[
$table
]))
{
return
$this
->
table
Q
ueue
[
$table
];
}
// In rare cases we might *only* have aliased versions of the table.
if
(
!
empty
(
$this
->
tables
[
$this
->
view
->
storage
->
get
(
'base_table'
)][
$table
]))
{
$alias
=
$this
->
tables
[
$this
->
view
->
storage
->
get
(
'base_table'
)][
$table
][
'alias'
];
if
(
!
empty
(
$this
->
table
_q
ueue
[
$alias
]))
{
return
$this
->
table
_q
ueue
[
$alias
];
if
(
!
empty
(
$this
->
table
Q
ueue
[
$alias
]))
{
return
$this
->
table
Q
ueue
[
$alias
];
}
}
}
...
...
@@ -734,7 +734,7 @@ public function addField($table, $field, $alias = '', $params = array()) {
$alias
=
$this
->
view
->
storage
->
get
(
'base_field'
);
}
if
(
$table
&&
empty
(
$this
->
table
_q
ueue
[
$table
]))
{
if
(
$table
&&
empty
(
$this
->
table
Q
ueue
[
$table
]))
{
$this
->
ensureTable
(
$table
);
}
...
...
@@ -772,7 +772,7 @@ public function addField($table, $field, $alias = '', $params = array()) {
}
// Keep track of all aliases used.
$this
->
field
_a
liases
[
$table
][
$field
]
=
$alias
;
$this
->
field
A
liases
[
$table
][
$field
]
=
$alias
;
return
$alias
;
}
...
...
@@ -979,7 +979,7 @@ public function addGroupBy($clause) {
* @see \Drupal\views\Plugin\views\query\Sql::addField
*/
protected
function
getFieldAlias
(
$table_alias
,
$field
)
{
return
isset
(
$this
->
field
_aliases
[
$table_alias
][
$field
])
?
$this
->
field_a
liases
[
$table_alias
][
$field
]
:
FALSE
;
return
isset
(
$this
->
field
Aliases
[
$table_alias
][
$field
])
?
$this
->
fieldA
liases
[
$table_alias
][
$field
]
:
FALSE
;
}
/**
...
...
@@ -1022,7 +1022,7 @@ protected function buildCondition($where = 'where') {
$has_filter
=
FALSE
;
$main_group
=
db_and
();
$filter_group
=
$this
->
group
_o
perator
==
'OR'
?
db_or
()
:
db_and
();
$filter_group
=
$this
->
group
O
perator
==
'OR'
?
db_or
()
:
db_and
();
foreach
(
$this
->
$where
as
$group
=>
$info
)
{
...
...
@@ -1096,7 +1096,7 @@ protected function getNonAggregates() {
}
if
(
!
empty
(
$field
[
'function'
]))
{
$this
->
has
_a
ggregate
=
TRUE
;
$this
->
has
A
ggregate
=
TRUE
;
}
// This is a formula, using no tables.
elseif
(
empty
(
$field
[
'table'
]))
{
...
...
@@ -1106,7 +1106,7 @@ protected function getNonAggregates() {
$non_aggregates
[]
=
$fieldname
;
}
if
(
$this
->
get
_count_o
ptimized
)
{
if
(
$this
->
get
CountO
ptimized
)
{
// We only want the first field in this case.
break
;
}
...
...
@@ -1143,7 +1143,7 @@ protected function compileFields($query) {
$query
->
addExpression
(
$string
,
$fieldname
,
$placeholders
);
}
$this
->
has
_a
ggregate
=
TRUE
;
$this
->
has
A
ggregate
=
TRUE
;
}
// This is a formula, using no tables.
elseif
(
empty
(
$field
[
'table'
]))
{
...
...
@@ -1157,7 +1157,7 @@ protected function compileFields($query) {
$query
->
addField
(
!
empty
(
$field
[
'table'
])
?
$field
[
'table'
]
:
$this
->
view
->
storage
->
get
(
'base_table'
),
$field
[
'field'
],
$fieldname
);
}
if
(
$this
->
get
_count_o
ptimized
)
{
if
(
$this
->
get
CountO
ptimized
)
{
// We only want the first field in this case.
break
;
}
...
...
@@ -1173,7 +1173,7 @@ protected function compileFields($query) {
*/
public
function
query
(
$get_count
=
FALSE
)
{
// Check query distinct value.
if
(
empty
(
$this
->
no
_d
istinct
)
&&
$this
->
distinct
&&
!
empty
(
$this
->
fields
))
{
if
(
empty
(
$this
->
no
D
istinct
)
&&
$this
->
distinct
&&
!
empty
(
$this
->
fields
))
{
$base_field_alias
=
$this
->
addField
(
$this
->
view
->
storage
->
get
(
'base_table'
),
$this
->
view
->
storage
->
get
(
'base_field'
));
$this
->
addGroupBy
(
$base_field_alias
);
$distinct
=
TRUE
;
...
...
@@ -1186,16 +1186,16 @@ public function query($get_count = FALSE) {
if
(
$get_count
&&
!
$this
->
groupby
)
{
foreach
(
$this
->
fields
as
$field
)
{
if
(
!
empty
(
$field
[
'distinct'
])
||
!
empty
(
$field
[
'function'
]))
{
$this
->
get
_count_o
ptimized
=
FALSE
;
$this
->
get
CountO
ptimized
=
FALSE
;
break
;
}
}
}
else
{
$this
->
get
_count_o
ptimized
=
FALSE
;
$this
->
get
CountO
ptimized
=
FALSE
;
}
if
(
!
isset
(
$this
->
get
_count_o
ptimized
))
{
$this
->
get
_count_o
ptimized
=
TRUE
;
if
(
!
isset
(
$this
->
get
CountO
ptimized
))
{
$this
->
get
CountO
ptimized
=
TRUE
;
}
$options
=
array
();
...
...
@@ -1228,20 +1228,20 @@ public function query($get_count = FALSE) {
}
// Add all the tables to the query via joins. We assume all LEFT joins.
foreach
(
$this
->
table
_q
ueue
as
$table
)
{
foreach
(
$this
->
table
Q
ueue
as
$table
)
{
if
(
is_object
(
$table
[
'join'
]))
{
$table
[
'join'
]
->
buildJoin
(
$query
,
$table
,
$this
);
}
}
// Assemble the groupby clause, if any.
$this
->
has
_a
ggregate
=
FALSE
;
$this
->
has
A
ggregate
=
FALSE
;
$non_aggregates
=
$this
->
getNonAggregates
();
if
(
count
(
$this
->
having
))
{
$this
->
has
_a
ggregate
=
TRUE
;
$this
->
has
A
ggregate
=
TRUE
;
}
$groupby
=
array
();
if
(
$this
->
has
_a
ggregate
&&
(
!
empty
(
$this
->
groupby
)
||
!
empty
(
$non_aggregates
)))
{
if
(
$this
->
has
A
ggregate
&&
(
!
empty
(
$this
->
groupby
)
||
!
empty
(
$non_aggregates
)))
{
$groupby
=
array_unique
(
array_merge
(
$this
->
groupby
,
$non_aggregates
));
}
...
...
@@ -1277,7 +1277,7 @@ public function query($get_count = FALSE) {
}
}
if
(
!
$this
->
get
_count_o
ptimized
)
{
if
(
!
$this
->
get
CountO
ptimized
)
{
// we only add the orderby if we're not counting.
if
(
$this
->
orderby
)
{
foreach
(
$this
->
orderby
as
$order
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment