]> git.joonet.de Git - adminer.git/commitdiff
Move $VERSION and version() to VERSION
authorJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 16:52:49 +0000 (17:52 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 17:39:30 +0000 (18:39 +0100)
adminer/dump.inc.php
adminer/file.inc.php
adminer/include/adminer.inc.php
adminer/include/bootstrap.inc.php
adminer/include/design.inc.php
adminer/include/functions.inc.php
adminer/include/version.inc.php
compile.php
editor/include/adminer.inc.php
phpstan.neon

index 0284c655c7633ab98dfff92a9e114d5246eb4ab4..dc9eae27b539af79f4493d1d5af6398523b60e44 100644 (file)
@@ -16,7 +16,7 @@ if ($_POST && !$error) {
        $is_sql = preg_match('~sql~', $_POST["format"]);
 
        if ($is_sql) {
-               echo "-- Adminer $VERSION " . $drivers[DRIVER] . " " . str_replace("\n", " ", $connection->server_info) . " dump\n\n";
+               echo "-- Adminer " . VERSION . " " . $drivers[DRIVER] . " " . str_replace("\n", " ", $connection->server_info) . " dump\n\n";
                if (JUSH == "sql") {
                        echo "SET NAMES utf8;
 SET time_zone = '+00:00';
index 4ae73a5c699bbfab6d13f9ef3f95d458efef5dce..01b917c5ac68f64922402bbcf20f7a10c5df1593 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace Adminer;
 
-if (substr($VERSION, -4) != '-dev') {
+if (substr(VERSION, -4) != '-dev') {
        if ($_SERVER["HTTP_IF_MODIFIED_SINCE"]) {
                header("HTTP/1.1 304 Not Modified");
                exit;
index 0e5b21a75156198f600147b5eb40d1758489c35c..77083bdac0a8c404658e8dd394c70e398112fd76 100644 (file)
@@ -946,10 +946,10 @@ class Adminer {
        * @param string $missing can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema
        */
        function navigation(string $missing): void {
-               global $VERSION, $drivers, $connection, $adminer;
-               echo "<h1>" . $adminer->name() . " <span class='version'>$VERSION";
+               global $drivers, $connection, $adminer;
+               echo "<h1>" . $adminer->name() . " <span class='version'>" . VERSION;
                $new_version = $_COOKIE["adminer_version"];
-               echo " <a href='https://www.adminer.org/#download'" . target_blank() . " id='version'>" . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
+               echo " <a href='https://www.adminer.org/#download'" . target_blank() . " id='version'>" . (version_compare(VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
                echo "</span></h1>\n";
                // this is matched by compile.php
                switch_lang();
index 3fdf2266d3c2552c1c03bbbf570f0d132b58ea74..f77d246104b6598c717913088d7a556807d35aa6 100644 (file)
@@ -39,7 +39,7 @@ if ($_GET["script"] == "version") {
        exit;
 }
 
-global $adminer, $connection, $driver, $drivers, $error, $HTTPS, $LANG, $langs, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function
+global $adminer, $connection, $driver, $drivers, $error, $HTTPS, $LANG, $langs, $permanent, $has_token, $token, $translations; // allows including Adminer inside a function
 
 if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility
        $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"];
index a2a125e21ef5317a1a27a1c25a27efac43cb31af..2c20b48c843b04e7a2795ae4e5eca689f30d3bf4 100644 (file)
@@ -7,7 +7,7 @@ namespace Adminer;
 * @param string $title2 used after colon in title and heading, should be HTML escaped
 */
 function page_header(string $title, string $error = "", $breadcrumb = array(), string $title2 = ""): void {
-       global $LANG, $VERSION, $adminer, $drivers;
+       global $LANG, $adminer, $drivers;
        page_headers();
        if (is_ajax() && $error) {
                page_messages($error);
@@ -77,7 +77,7 @@ fQIDAQAB
                }
        }
        echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick"
-               . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '$VERSION', '" . js_escape(ME) . "', '" . get_token() . "')") // $token may be empty in auth.inc.php
+               . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") // $token may be empty in auth.inc.php
                . "});
 document.body.classList.replace('nojs', 'js');
 const offlineMessage = '" . js_escape(lang('You are offline.')) . "';
index 947d0775a885493f432d18209f9ea99399f54a18..52f97b8ed584775280276cbd83489012ceffcb8d 100644 (file)
@@ -26,12 +26,6 @@ function driver() {
        return $driver;
 }
 
-/** Get Adminer version */
-function version(): string {
-       global $VERSION;
-       return $VERSION;
-}
-
 /** Unescape database identifier
 * @param string $idf text inside ``
 */
index bc07b271821c3cf7bf97f2a05fd555ebb2421156..456c8bf26fa50124eac4cfbba9b20996a25a4c46 100644 (file)
@@ -1,4 +1,4 @@
 <?php
 namespace Adminer;
 
-$VERSION = "5.1.1-dev";
+const VERSION = "5.1.1-dev";
index c089d8776e66cf06ed7c464b4b499e2bcbc8e87d..107ec169d38db48fc16f1296939c607a99404870 100755 (executable)
@@ -288,7 +288,7 @@ $connection = (object) array('flavor' => ''); // used in support()
 $features = array("check", "call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "sql", "status", "trigger", "type", "user" => "privileges", "variables", "view");
 $lang_ids = array(); // global variable simplifies usage in a callback function
 $file = file_get_contents(__DIR__ . "/$project/index.php");
-$file = preg_replace('~\*/~', "* @version $VERSION\n*/", $file, 1);
+$file = preg_replace('~\*/~', "* @version " . Adminer\VERSION . "\n*/", $file, 1);
 if ($vendor) {
        $_GET[$vendor] = true; // to load the driver
        include_once __DIR__ . $driver_path;
@@ -357,7 +357,7 @@ if (function_exists('stripTypes')) {
        $file = stripTypes($file);
 }
 $file = preg_replace_callback("~compile_file\\('([^']+)'(?:, '([^']*)')?\\)~", 'compile_file', $file); // integrate static files
-$replace = 'preg_replace("~\\\\\\\\?.*~", "", ME) . "?file=\1&version=' . $VERSION . '"';
+$replace = 'preg_replace("~\\\\\\\\?.*~", "", ME) . "?file=\1&version=' . Adminer\VERSION . '"';
 $file = preg_replace('~\.\./adminer/static/(default\.css)~', '<?php echo h(' . $replace . '); ?>', $file);
 $file = preg_replace('~"\.\./adminer/static/(functions\.js)"~', $replace, $file);
 $file = preg_replace('~\.\./adminer/static/([^\'"]*)~', '" . h(' . $replace . ') . "', $file);
@@ -366,6 +366,6 @@ if (function_exists('phpShrink')) {
        $file = phpShrink($file);
 }
 
-$filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($vendor ? "-$vendor" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";
+$filename = $project . (preg_match('~-dev$~', Adminer\VERSION) ? "" : "-" . Adminer\VERSION) . ($vendor ? "-$vendor" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";
 file_put_contents($filename, $file);
 echo "$filename created (" . strlen($file) . " B).\n";
index c23c0428ecf950da2a39e85141a4c2cadcc808b1..60a88ffb47d61e9279edd114c9d2e2ed46109355 100644 (file)
@@ -596,10 +596,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
        }
 
        function navigation($missing) {
-               global $VERSION, $adminer;
-               echo "<h1>" . $adminer->name() . " <span class='version'>$VERSION";
+               global $adminer;
+               echo "<h1>" . $adminer->name() . " <span class='version'>" . VERSION;
                $new_version = $_COOKIE["adminer_version"];
-               echo " <a href='https://www.adminer.org/editor/#download'" . target_blank() . " id='version'>" . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
+               echo " <a href='https://www.adminer.org/editor/#download'" . target_blank() . " id='version'>" . (version_compare(VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
                echo "</span></h1>\n";
                switch_lang();
                if ($missing == "auth") {
index 80deae6bb5ca865bc6ecca65f6a9765f7621e65d..60a2766423cbf4b593dcb27a286bce3391be9e2d 100644 (file)
@@ -12,7 +12,7 @@ parameters:
                - identifier: includeOnce.fileNotFound # ./adminer-plugins.php
                - "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions
                - "~an unknown class OCI-?Lob~" # this looks like PHPStan bug
-               - "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations|VERSION) might not be defined~" # declared in bootstrap.inc.php
+               - "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations) might not be defined~" # declared in bootstrap.inc.php
                - "~expects int, float given~" # this will work
                - "~expects bool~" # truthy values
                - "~fread expects int<1, max>, 100000~" # 1e6