($server . $username != "" ? $username : ini_get("mysqli.default_user")),
($server . $username . $password != "" ? $password : ini_get("mysqli.default_pw")),
null,
- (is_numeric($port) ? $port : ini_get("mysqli.default_port")),
- (is_numeric($port) ? intval($port) : null),
+ (is_numeric($port) ? intval($port) : ini_get("mysqli.default_port")),
+ (is_numeric($port) ? $port : null),
($ssl ? ($ssl['verify'] !== false ? 2048 : 64) : 0) // 2048 - MYSQLI_CLIENT_SSL, 64 - MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT (not available before PHP 5.6.16)
);
$this->options(MYSQLI_OPT_LOCAL_INFILE, false);
$TABLE = $_GET["edit"];
$fields = fields($TABLE);
-$where = (isset($_GET["select"]) ? ($_POST["check"] && count($_POST["check"]) == 1 ? where_check($_POST["check"][0], $fields) : "") : where($_GET, $fields));
+$where = (isset($_GET["select"])
+ ? ($_POST["check"] && count($_POST["check"]) == 1 ? where_check($_POST["check"][0], $fields) : "")
+ : where($_GET, $fields)
+);
$update = (isset($_GET["select"]) ? $_POST["edit"] : $where);
foreach ($fields as $name => $field) {
if (!isset($field["privileges"][$update ? "update" : "insert"]) || adminer()->fieldName($field) == "" || $field["generated"]) {
queries_redirect(
$location,
lang('Item has been deleted.'),
- driver()->delete($TABLE, $query_where, !$unique_array)
+ driver()->delete($TABLE, $query_where, $unique_array ? 0 : 1)
);
} else {
queries_redirect(
$location,
lang('Item has been updated.'),
- driver()->update($TABLE, $set, $query_where, !$unique_array)
+ driver()->update($TABLE, $set, $query_where, $unique_array ? 0 : 1)
);
if (is_ajax()) {
page_headers();
if (!support("table") && !$fields) { // used by Mongo and SimpleDB
if (!$where) { // insert
- $result = driver()->select($TABLE, array("*"), $where, array("*"));
+ $result = driver()->select($TABLE, array("*"), array(), array("*"));
$row = ($result ? $result->fetch_assoc() : false);
if (!$row) {
$row = array(driver()->primary => "");
}
/** Field caption used in select and edit
- * @param Field $field
+ * @param Field|RoutineField $field
* @param int $order order of column in select
* @return string HTML code, "" to ignore field
*/
/** Get descriptions of selected data
* @param list<string[]> $rows all data to print
- * @param ForeignKey[] $foreignKeys
+ * @param list<ForeignKey>[] $foreignKeys
* @return list<string[]>
*/
function rowDescriptions(array $rows, array $foreignKeys): array {
echo "</div></fieldset>\n";
}
- /** Print limit box in select
- * @param string $limit result of selectLimitProcess()
- */
- function selectLimitPrint(string $limit): void {
+ /** Print limit box in select */
+ function selectLimitPrint(int $limit): void {
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
echo "<input type='number' name='limit' class='size' value='" . h($limit) . "'>";
echo script("qsl('input').oninput = selectFieldChange;", "");
return $return;
}
- /** Process limit box in select
- * @return string expression to use in LIMIT, will be escaped
- */
- function selectLimitProcess(): string {
- return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
+ /** Process limit box in select */
+ function selectLimitProcess(): int {
+ return (isset($_GET["limit"]) ? intval($_GET["limit"]) : 50);
}
/** Process length box in select
/** Process extras in select form
* @param string[] $where AND conditions
- * @param ForeignKey[] $foreignKeys
+ * @param list<ForeignKey>[] $foreignKeys
* @return bool true if processed, false to process other parts of form
*/
function selectEmailProcess(array $where, array $foreignKeys): bool {
}
/** Functions displayed in edit form
- * @param Field $field
- * @return list<string>
+ * @param Field|array{null:bool} $field
+ * @return string[]
*/
function editFunctions(array $field): array {
$return = ($field["null"] ? "NULL/" : "");
}
echo "</script>\n";
}
- echo script("syntaxHighlighting('" . (is_object(connection()) ? preg_replace('~^(\d\.?\d).*~s', '\1', connection()->server_info) : "") . "'"
+ echo script("syntaxHighlighting('" . preg_replace('~^(\d\.?\d).*~s', '\1', connection()->server_info) . "'"
. (connection()->flavor == 'maria' ? ", 'maria'" : (connection()->flavor == 'cockroach' ? ", 'cockroach'" : "")) . ");"
);
}
* @param int|numeric-string $limit
* @return string[] $orgtables
*/
-function print_select_result($result, $connection2 = null, array $orgtables = array(), $limit = 0): array {
+function print_select_result($result, Db $connection2 = null, array $orgtables = array(), $limit = 0): array {
$links = array(); // colno => orgtable - create links from these columns
$indexes = array(); // orgtable => array(column => colno) - primary keys
$columns = array(); // orgtable => array(column => ) - not selected columns in primary key
$TABLE,
$set,
" WHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($unique_idf, $fields),
- !$is_group && !$primary,
+ ($is_group || $primary ? 0 : 1),
" "
);
if (!$result) {
$page = $_GET["page"];
if ($page == "last") {
$found_rows = get_val(count_rows($TABLE, $where, $is_group, $group));
- $page = floor(max(0, intval($found_rows) - 1) / $limit);
+ $page = floor(max(0, intval($found_rows) - 1) / intval($limit));
}
$select2 = $select;
$found_rows = ($page ? $page * $limit : 0) + count($rows);
} elseif (JUSH != "sql" || !$is_group) {
$found_rows = ($is_group ? false : found_rows($table_status, $where));
- if ($found_rows < max(1e4, 2 * ($page + 1) * $limit)) {
+ if (intval($found_rows) < max(1e4, 2 * ($page + 1) * intval($limit))) {
// slow with big tables
$found_rows = first(slow_query(count_rows($TABLE, $where, $is_group, $group)));
} else {
if ($pagination) {
echo (($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit
? '<p><a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" class="loadmore">' . lang('Load more data') . '</a>'
- . script("qsl('a').onclick = partial(selectLoadMore, " . (+$limit) . ", '" . lang('Loading') . "…');", "")
+ . script("qsl('a').onclick = partial(selectLoadMore, " . intval($limit) . ", '" . lang('Loading') . "…');", "")
: ''
);
echo "\n";
// display first, previous 4, next 4 and last page
$max_page = ($found_rows === false
? $page + (count($rows) >= $limit ? 2 : 1)
- : floor(($found_rows - 1) / $limit)
+ : floor(($found_rows - 1) / intval($limit))
);
echo "<fieldset>";
if (JUSH != "simpledb") {
function selectLimitPrint($limit) {
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
- echo html_select("limit", array("", "50", "100"), $limit);
+ echo html_select("limit", array("", 50, 100), $limit);
echo "</div></fieldset>\n";
}
}
function selectLimitProcess() {
- return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
+ return (isset($_GET["limit"]) ? intval($_GET["limit"]) : 50);
}
function selectLengthProcess() {
ignoreErrors:
# need to fix
- - "~^Function Adminer\\\\fields_from_edit\\(\\) should return~" # Mongo and SimpleDB
+ - "~^Function Adminer\\\\fields_from_edit\\(\\) should return|Adminer\\\\Driver::\\$primary~" # Mongo and SimpleDB
- "~Adminer\\\\Result.*mysqli_result~" # mysqli_result
+ - "~Function Adminer\\\\queries\\(\\) never returns Adminer\\\\Result~" # mysqli_result
# not real problems
- identifier: include.fileNotFound # includes in include/ relative from index.php
- "~an unknown class OCI-?Lob~" # this looks like PHPStan bug
- "~^Variable \\$error might not be defined~" # declared in bootstrap.inc.php
- "~^Constant LANG not found~" # defined in lang.inc.php
+ - "~ an undefined \\w+ Adminer\\\\Db::~" # defined in that versions of Db
+ - "~^Call to an undefined method Adminer\\\\Result::seek~" # defined in MS SQL
+ - "~^Call to an undefined method Adminer\\\\Driver::setUserTypes~" # defined in PostgreSQL
- "~expects int, float given~" # this will work
- "~expects bool~" # truthy values
- "~fread expects int<1, max>, 100000~" # 1e6
- adminer/include/pdo.inc.php
- adminer/drivers/*
- -
- message: "~ to an undefined ~" # PostgreSQL has this in its version of Db
- path: adminer/drivers/pgsql.inc.php
-
# it probably doesn't like $ar[$key] instead of isset($ar[$key]) and thinks that $ar[$key] is always set
- identifier: identical.alwaysFalse
- identifier: notEqual.alwaysFalse
- identifier: notIdentical.alwaysTrue
+ - identifier: booleanNot.alwaysTrue
- identifier: booleanNot.alwaysFalse
- identifier: booleanAnd.alwaysFalse
- identifier: booleanAnd.leftAlwaysTrue
- compile.php # compile_file()
excludePaths:
- adminer/adminer-plugins*
- - adminer/lang/
- adminer/designs.php
- adminer/elastic.php
- adminer/sqlite.php