Skip to content

Commit

Permalink
Simplify DatabaseInterface fetchValue logic
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 31, 2020
1 parent aadb6ab commit 54e27c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions libraries/classes/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -1345,16 +1345,14 @@ public function fetchValue(
return $value;
}

// if $field is an integer use non associative mysql fetch function
if (is_int($field)) {
$fetch_function = 'fetchRow';
} else {
$fetch_function = 'fetchAssoc';
}

// get requested row
for ($i = 0; $i <= $row_number; $i++) {
$row = $this->$fetch_function($result);
// if $field is an integer use non associative mysql fetch function
if (is_int($field)) {
$row = $this->fetchRow($result);
continue;
}
$row = $this->fetchAssoc($result);
}
$this->freeResult($result);

Expand Down
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,11 @@ parameters:
count: 1
path: libraries/classes/DatabaseInterface.php

-
message: "#^Cannot access offset int\\|string on array\\|bool\\.$#"
count: 1
path: libraries/classes/DatabaseInterface.php

-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getProtoInfo\\(\\) should return bool\\|int but returns int\\|string\\.$#"
count: 1
Expand Down

0 comments on commit 54e27c6

Please sign in to comment.