]> git.joonet.de Git - adminer.git/commitdiff
PHP: Use ?:
authorJakub Vrana <jakub@vrana.cz>
Thu, 6 Mar 2025 17:12:22 +0000 (18:12 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 6 Mar 2025 17:12:22 +0000 (18:12 +0100)
17 files changed:
adminer/call.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/include/auth.inc.php
adminer/include/design.inc.php
adminer/include/functions.inc.php
adminer/include/lang.inc.php
adminer/indexes.inc.php
adminer/procedure.inc.php
adminer/schema.inc.php
adminer/select.inc.php
compile.php
lang.php
plugins/drivers/clickhouse.php
plugins/drivers/elastic.php
plugins/drivers/elastic5.php
plugins/drivers/simpledb.php

index 8262e6a26e51b80ddb8d3ba1f15254d67afe6517..33f4cd787acb1d2510e3ad2eb5f149757713a818 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace Adminer;
 
-$PROCEDURE = ($_GET["name"] ? $_GET["name"] : $_GET["call"]);
+$PROCEDURE = ($_GET["name"] ?: $_GET["call"]);
 page_header(lang('Call') . ": " . h($PROCEDURE), $error);
 
 $routine = routine($_GET["call"], (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
index 2ef77f655461a19522be45927293bec1f2b135ec..e4d90d41799f27dc4ef4630cf104e14a618342fb 100644 (file)
@@ -654,8 +654,8 @@ if (!defined('Adminer\DRIVER')) {
                                        "table" => idf_unescape($match[4] != "" ? $match[4] : $match[3]),
                                        "source" => array_map('Adminer\idf_unescape', $source[0]),
                                        "target" => array_map('Adminer\idf_unescape', $target[0]),
-                                       "on_delete" => ($match[6] ? $match[6] : "RESTRICT"),
-                                       "on_update" => ($match[7] ? $match[7] : "RESTRICT"),
+                                       "on_delete" => ($match[6] ?: "RESTRICT"),
+                                       "on_update" => ($match[7] ?: "RESTRICT"),
                                );
                        }
                }
index 518f217e0c7d328194e8ea8332df890c84c76fe7..009c8a992ed6a708c9a05de40f1bb77df9549e4c 100644 (file)
@@ -258,7 +258,7 @@ ORDER BY 1"
 
        function get_current_db() {
                global $connection;
-               $db = $connection->_current_db ? $connection->_current_db : DB;
+               $db = $connection->_current_db ?: DB;
                unset($connection->_current_db);
                return $db;
        }
@@ -272,7 +272,7 @@ ORDER BY 1"
 
        function views_table($columns) {
                $owner = where_owner('');
-               return "(SELECT $columns FROM all_views WHERE " . ($owner ? $owner : "rownum < 0") . ")";
+               return "(SELECT $columns FROM all_views WHERE " . ($owner ?: "rownum < 0") . ")";
        }
 
        function tables_list() {
@@ -503,7 +503,7 @@ AND c_src.TABLE_NAME = " . q($table);
 
        function schemas() {
                $return = get_vals("SELECT DISTINCT owner FROM dba_segments WHERE owner IN (SELECT username FROM dba_users WHERE default_tablespace NOT IN ('SYSTEM','SYSAUX')) ORDER BY 1");
-               return ($return ? $return : get_vals("SELECT DISTINCT owner FROM all_tables WHERE tablespace_name = " . q(DB) . " ORDER BY 1"));
+               return ($return ?: get_vals("SELECT DISTINCT owner FROM all_tables WHERE tablespace_name = " . q(DB) . " ORDER BY 1"));
        }
 
        function get_schema() {
index 48602037eff0842d3c3220058508caa64f0fc90a..965b54f8adef8c40a90b3600fe718af126c70af0 100644 (file)
@@ -133,7 +133,7 @@ function auth_error($error) {
                $error = lang('Session support must be enabled.');
        }
        $params = session_get_cookie_params();
-       cookie("adminer_key", ($_COOKIE["adminer_key"] ? $_COOKIE["adminer_key"] : rand_string()), $params["lifetime"]);
+       cookie("adminer_key", ($_COOKIE["adminer_key"] ?: rand_string()), $params["lifetime"]);
        page_header(lang('Login'), $error, null);
        echo "<form action='' method='post'>\n";
        echo "<div>";
index 48a2fcacf71539e78e5802b03336e1c01a90438a..d54097d6bf38099356d115b380877d7b9cdf89bf 100644 (file)
@@ -75,7 +75,7 @@ var thousandsSeparator = '<?php echo js_escape(lang(',')); ?>';
 <?php
        if ($breadcrumb !== null) {
                $link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1);
-               echo '<p id="breadcrumb"><a href="' . h($link ? $link : ".") . '">' . $drivers[DRIVER] . '</a> » ';
+               echo '<p id="breadcrumb"><a href="' . h($link ?: ".") . '">' . $drivers[DRIVER] . '</a> » ';
                $link = substr(preg_replace('~\b(db|ns)=[^&]*&~', '', ME), 0, -1);
                $server = $adminer->serverName(SERVER);
                $server = ($server != "" ? $server : lang('Server'));
index b188522129c685b41526615bbac47aaf70611604..18734af91b338df0bce369922d7940e2ed3cbe28 100644 (file)
@@ -851,7 +851,7 @@ function hidden_fields_get() {
 */
 function table_status1($table, $fast = false) {
        $return = table_status($table, $fast);
-       return ($return ? $return : array("Name" => $table));
+       return ($return ?: array("Name" => $table));
 }
 
 /** Find out foreign keys for each column
@@ -1317,7 +1317,7 @@ var timeout = setTimeout(function () {
        }
        ob_flush();
        flush();
-       $return = @get_key_vals(($slow_query ? $slow_query : $query), $connection2, false); // @ - may be killed
+       $return = @get_key_vals(($slow_query ?: $query), $connection2, false); // @ - may be killed
        if ($connection2) {
                echo script("clearTimeout(timeout);");
                ob_flush();
index 0fbb8ca2a50f68fe6110517804a982e4f09fb13c..df0622d22e8166559c598e46c5971153d2b4b60b 100644 (file)
@@ -65,7 +65,7 @@ function get_lang() {
 */
 function lang($idf, $number = null) {
        global $LANG, $translations;
-       $translation = ($translations[$idf] ? $translations[$idf] : $idf);
+       $translation = ($translations[$idf] ?: $idf);
        if (is_array($translation)) {
                $pos = ($number == 1 ? 0
                        : ($LANG == 'cs' || $LANG == 'sk' ? ($number && $number < 5 ? 1 : 2) // different forms for 1, 2-4, other
index 8e3b585ee1d3c844811da4cf6525ea77c530b5b4..84f02257ea3a3144360cd97927c2b389fe5b2aa6 100644 (file)
@@ -37,7 +37,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
                                        $desc = $index["descs"][$key];
                                        $set[] = idf_escape($column) . ($length ? "(" . (+$length) . ")" : "") . ($desc ? " DESC" : "");
                                        $columns[] = $column;
-                                       $lengths[] = ($length ? $length : null);
+                                       $lengths[] = ($length ?: null);
                                        $descs[] = $desc;
                                }
                        }
index ed0d007e6aa8b22e38ece0b1cc7913704f1145b9..6e64860dfe54f6807f247896afa4945c10571c81 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace Adminer;
 
-$PROCEDURE = ($_GET["name"] ? $_GET["name"] : $_GET["procedure"]);
+$PROCEDURE = ($_GET["name"] ?: $_GET["procedure"]);
 $routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
 $row = $_POST;
 $row["fields"] = (array) $row["fields"];
index 140605259e50d28b2bcdc66e6c6c011cd041b247..3a5d5c3b0f6119a4c3113935bb8081597fe5e7dd 100644 (file)
@@ -5,7 +5,7 @@ page_header(lang('Database schema'), "", array(), h(DB . ($_GET["ns"] ? ".$_GET[
 
 $table_pos = array();
 $table_pos_js = array();
-$SCHEMA = ($_GET["schema"] ? $_GET["schema"] : $_COOKIE["adminer_schema-" . str_replace(".", "_", DB)]); // $_COOKIE["adminer_schema"] was used before 3.2.0 //! ':' in table name
+$SCHEMA = ($_GET["schema"] ?: $_COOKIE["adminer_schema-" . str_replace(".", "_", DB)]); // $_COOKIE["adminer_schema"] was used before 3.2.0 //! ':' in table name
 preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', $SCHEMA, $matches, PREG_SET_ORDER);
 foreach ($matches as $i => $match) {
        $table_pos[$match[1]] = array($match[2], $match[3]);
@@ -28,7 +28,7 @@ foreach (table_status('', true) as $table => $table_status) {
                $field["pos"] = $pos;
                $schema[$table]["fields"][$name] = $field;
        }
-       $schema[$table]["pos"] = ($table_pos[$table] ? $table_pos[$table] : array($top, 0));
+       $schema[$table]["pos"] = ($table_pos[$table] ?: array($top, 0));
        foreach ($adminer->foreignKeys($table) as $val) {
                if (!$val["db"]) {
                        $left = $base_left;
index 5eaff0fac6b58d9be879fc19807d0199b554a77d..b74afc4a5cffb165b77b271ead301c9961809418 100644 (file)
@@ -33,7 +33,7 @@ if ($_GET["val"] && is_ajax()) {
        header("Content-Type: text/plain; charset=utf-8");
        foreach ($_GET["val"] as $unique_idf => $row) {
                $as = convert_field($fields[key($row)]);
-               $select = array($as ? $as : idf_escape(key($row)));
+               $select = array($as ?: idf_escape(key($row)));
                $where[] = where_check($unique_idf, $fields);
                $return = $driver->select($TABLE, $select, $where, $select);
                if ($return) {
index 0d7dcb6332c6be84c9d9e22a6b982ee9e6240d64..25286f9f83dc02a5340b038eadb0623e16aa4746 100755 (executable)
@@ -19,7 +19,7 @@ function add_quo_slashes($s) {
 function remove_lang($match) {
        global $translations;
        $idf = strtr($match[2], array("\\'" => "'", "\\\\" => "\\"));
-       $s = ($translations[$idf] ? $translations[$idf] : $idf);
+       $s = ($translations[$idf] ?: $idf);
        if ($match[3] == ",") { // lang() has parameters
                return $match[1] . (is_array($s) ? "lang(array('" . implode("', '", array_map('add_apo_slashes', $s)) . "')," : "sprintf('" . add_apo_slashes($s) . "',");
        }
index b748711e136febc9c0e0d81f618e450cf018476b..15738fef27568487ced8ca79aa2caa39684bc269 100755 (executable)
--- a/lang.php
+++ b/lang.php
@@ -28,7 +28,7 @@ foreach (
        }
 }
 
-foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ? $_SESSION["lang"] : "*") . ".inc.php") as $filename) {
+foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.php") as $filename) {
        $messages = $messages_all;
        $file = file_get_contents($filename);
        $file = str_replace("\r", "", $file);
index fb71a3326c6430922be242d2636fd4a504a0d36e..ae6854f183cc89574c7b4a3ac407b7845302ebf8 100644 (file)
@@ -57,7 +57,7 @@ if (isset($_GET["clickhouse"])) {
 
                        function connect($server, $username, $password) {
                                preg_match('~^(https?://)?(.*)~', $server, $match);
-                               $this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
+                               $this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
                                $return = $this->query('SELECT 1');
                                return (bool) $return;
                        }
index 579b8bc320476de05ca00fde012da70480349ffb..465cedb33abe2755159b7d676245e963d2b7e0dd 100644 (file)
@@ -78,7 +78,7 @@ if (isset($_GET["elastic"])) {
                         */
                        function connect($server, $username, $password) {
                                preg_match('~^(https?://)?(.*)~', $server, $match);
-                               $this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
+                               $this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
                                $return = $this->query('');
                                if ($return) {
                                        $this->server_info = $return['version']['number'];
@@ -529,7 +529,7 @@ if (isset($_GET["elastic"])) {
                $properties = array();
                foreach ($fields as $f) {
                        $field_name = trim($f[1][0]);
-                       $field_type = trim($f[1][1] ? $f[1][1] : "text");
+                       $field_type = trim($f[1][1] ?: "text");
                        $properties[$field_name] = array(
                                'type' => $field_type
                        );
index 46ce2468aeb5365398b77f5e516cfca74309e7e5..f2301dfffdb30318c7d35fe4691ed86b12a81bbb 100644 (file)
@@ -68,7 +68,7 @@ if (isset($_GET["elastic5"])) {
 
                        function connect($server, $username, $password) {
                                preg_match('~^(https?://)?(.*)~', $server, $match);
-                               $this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
+                               $this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
                                $return = $this->query('');
                                if ($return) {
                                        $this->server_info = $return['version']['number'];
@@ -505,7 +505,7 @@ if (isset($_GET["elastic5"])) {
                $properties = array();
                foreach ($fields as $f) {
                        $field_name = trim($f[1][0]);
-                       $field_type = trim($f[1][1] ? $f[1][1] : "text");
+                       $field_type = trim($f[1][1] ?: "text");
                        $properties[$field_name] = array(
                                'type' => $field_type
                        );
index 6c6388263aae8ed15314e898029fcdf488e783db..241d17741604d6b4797541fab6bacc6a80d3fed4 100644 (file)
@@ -439,7 +439,7 @@ if (isset($_GET["simpledb"])) {
                }
                $connection->error = '';
                $tag = $action . "Result";
-               return ($xml->$tag ? $xml->$tag : true);
+               return ($xml->$tag ?: true);
        }
 
        function sdb_request_all($action, $tag, $params = array(), $timeout = 0) {