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

UPD deprecated getQuery(true) #311

Open
wants to merge 1 commit into
base: 3.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down Expand Up @@ -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(
Expand Down
15 changes: 13 additions & 2 deletions src/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
*
Expand Down