Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a deprecated flag in database query for union queries #20219

Merged
merged 1 commit into from
May 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion libraries/joomla/database/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ abstract class JDatabaseQuery
/**
* @var JDatabaseQueryElement The union element.
* @since 12.1
* @deprecated 4.0 Will be transformed and moved to $merge variable.
*/
protected $union = null;

/**
* @var JDatabaseQueryElement The unionAll element.
* @since 13.1
* @deprecated 4.0 Will be transformed and moved to $merge variable.
*/
protected $unionAll = null;

Expand Down Expand Up @@ -1497,8 +1499,11 @@ public function __clone()
* Usage (the $query base query MUST be a select query):
* $query->union('SELECT name FROM #__foo')
* $query->union('SELECT name FROM #__foo', true)
* $query->union(array('SELECT name FROM #__foo','SELECT name FROM #__bar'))
* $query->union($query2)->union($query3)
*
* The $query attribute as an array is deprecated and will not be supported in 4.0.
*
* $query->union(array('SELECT name FROM #__foo','SELECT name FROM #__bar'))
* $query->union(array($query2, $query3))
*
* @param mixed $query The JDatabaseQuery object or string to union.
Expand All @@ -1525,6 +1530,11 @@ public function union($query, $distinct = false, $glue = '')
$name = 'UNION ()';
}

if (is_array($query))
{
JLog::add('Query attribute as an array is deprecated.', JLog::WARNING, 'deprecated');
}

// Get the JDatabaseQueryElement if it does not exist
if (is_null($this->union))
{
Expand Down Expand Up @@ -1553,6 +1563,7 @@ public function union($query, $distinct = false, $glue = '')
* @see union
*
* @since 12.1
* @deprecated 4.0 Use union() instead.
*/
public function unionDistinct($query, $glue = '')
{
Expand Down Expand Up @@ -1776,6 +1787,9 @@ public function dateAdd($date, $interval, $datePart)
*
* Usage:
* $query->union('SELECT name FROM #__foo')
*
* The $query attribute as an array is deprecated and will not be supported in 4.0.
*
* $query->union(array('SELECT name FROM #__foo','SELECT name FROM #__bar'))
*
* @param mixed $query The JDatabaseQuery object or string to union.
Expand All @@ -1793,6 +1807,11 @@ public function unionAll($query, $distinct = false, $glue = '')
$glue = ')' . PHP_EOL . 'UNION ALL (';
$name = 'UNION ALL ()';

if (is_array($query))
{
JLog::add('Query attribute as an array is deprecated.', JLog::WARNING, 'deprecated');
}

// Get the JDatabaseQueryElement if it does not exist
if (is_null($this->unionAll))
{
Expand Down