From f98d8476683106a3f27899da3e76f8a7edfb317c Mon Sep 17 00:00:00 2001 From: Thomas Kuschel Date: Sun, 8 Sep 2024 09:02:26 +0200 Subject: [PATCH] UPD deprecated getQuery(true) --- src/DatabaseDriver.php | 6 ++++-- src/DatabaseInterface.php | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/DatabaseDriver.php b/src/DatabaseDriver.php index 87e77e38..7aef791e 100644 --- a/src/DatabaseDriver.php +++ b/src/DatabaseDriver.php @@ -988,10 +988,12 @@ public function getImporter() public function getQuery($new = false) { if ($new) { + $key = array_search(__FUNCTION__, array_column(debug_backtrace(), 'function')); + $btfile = 'Found in: ' . debug_backtrace()[$key]['file'] . ':' . debug_backtrace()[$key]['line']; trigger_deprecation( 'joomla/database', '2.2.0', - 'The parameter $new is deprecated and will be removed in 4.0, use %s::createQuery() instead.', + __FUNCTION__ . " with a \$new (true) parameter is deprecated and will be removed in 4.0, use %s::createQuery() instead. $btfile", self::class ); @@ -1748,7 +1750,7 @@ public function setQuery($query, $offset = 0, $limit = 0) if (\is_string($query)) { // Allows taking advantage of bound variables in a direct query: - $query = $this->getQuery(true)->setQuery($query); + $query = $this->createQuery()->setQuery($query); } elseif (!($query instanceof QueryInterface)) { throw new \InvalidArgumentException( sprintf( diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index 508b9b95..6cf9e8c6 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -48,6 +48,16 @@ public function connected(); */ public function createDatabase($options, $utf = true); + /** + * Create a new QueryInterface object. + * + * @return QueryInterface + * + * @since 3.0 + * @throws \RuntimeException + */ + public function createQuery(); + /** * Replace special placeholder representing binary field with the original string. * @@ -232,9 +242,10 @@ public function getPrefix(); public function getNumRows(); /** - * Get the current query object or a new QueryInterface object. + * Get the current query object. (Deprecated: Or a new QueryInterface object). * - * @param boolean $new False to return the current query object, True to return a new QueryInterface object. + * @param boolean $new False to return the current query object,{@deprecated 3.0 Use DatabaseInterface::getQuery() instead} + * True to return a new QueryInterface object.{@deprecated 3.0 Use DatabaseInterface::createQuery() instead} * * @return QueryInterface *