From 042c9016439c4f7caa867d91b215cea060283ebe Mon Sep 17 00:00:00 2001 From: Tomasz Narloch Date: Mon, 23 Apr 2018 12:46:33 +0200 Subject: [PATCH] Add a deprecated flag in database query for a few union/unionAll/unionDistinct --- libraries/joomla/database/query.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libraries/joomla/database/query.php b/libraries/joomla/database/query.php index 8b526ce029ea2..097e505a9f098 100644 --- a/libraries/joomla/database/query.php +++ b/libraries/joomla/database/query.php @@ -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; @@ -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. @@ -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)) { @@ -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 = '') { @@ -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. @@ -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)) {