Remove $GLOBALS['cached_affected_rows']

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-12-18 22:46:57 +00:00
parent c30bc4ddcc
commit e2de1af910
3 changed files with 6 additions and 11 deletions

View File

@ -6957,12 +6957,6 @@ parameters:
count: 1
path: src/DatabaseInterface.php
-
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:affectedRows\(\) should return int\|numeric\-string but returns mixed\.$#'
identifier: return.type
count: 1
path: src/DatabaseInterface.php
-
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:getColumnNames\(\) should return list\<string\> but returns array\<mixed\>\.$#'
identifier: return.type

View File

@ -137,6 +137,9 @@ class DatabaseInterface implements DbalInterface
private ListDatabase|null $databaseList = null;
private readonly Config $config;
/** @var int|numeric-string */
private static int|string $cachedAffectedRows = -1;
/** @param DbiExtension $extension Object to be used for database queries */
public function __construct(private DbiExtension $extension)
{
@ -199,7 +202,7 @@ class DatabaseInterface implements DbalInterface
}
if ($cacheAffectedRows) {
$GLOBALS['cached_affected_rows'] = $this->affectedRows($connectionType, false);
self::$cachedAffectedRows = $this->affectedRows($connectionType, false);
}
if ($this->config->config->debug->sql) {
@ -1785,7 +1788,7 @@ class DatabaseInterface implements DbalInterface
}
if ($getFromCache) {
return $GLOBALS['cached_affected_rows'];
return self::$cachedAffectedRows;
}
return $this->extension->affectedRows($this->connections[$connectionType->value]);

View File

@ -485,8 +485,6 @@ class Monitor
string $database,
string $query,
): array {
$GLOBALS['cached_affected_rows'] ??= null;
$return = [];
if ($database !== '') {
@ -503,7 +501,7 @@ class Monitor
$sqlQuery = preg_replace('/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $query);
$this->dbi->tryQuery($sqlQuery);
$return['affectedRows'] = $GLOBALS['cached_affected_rows'];
$return['affectedRows'] = $this->dbi->affectedRows();
$result = $this->dbi->tryQuery('EXPLAIN ' . $sqlQuery);
if ($result !== false) {