]> git.joonet.de Git - adminer.git/commitdiff
MongoDB: Display Authentication failed instead of exception
authorJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 09:42:05 +0000 (10:42 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 10:04:10 +0000 (11:04 +0100)
adminer/drivers/mongo.inc.php

index f2c0d7ed0018e9b8c1d8119352a6d9403c22ce24..ad06af5e8032f2898421b3f696ce61b49faea534 100644 (file)
@@ -13,7 +13,10 @@ if (isset($_GET["mongo"])) {
 
                        function connect($uri, $options) {
                                $class = 'MongoDB\Driver\Manager';
-                               return new $class($uri, $options);
+                               $return = new $class($uri, $options);
+                               $class = 'MongoDB\Driver\Command';
+                               $return->executeCommand('admin', new $class(array('ping' => 1)));
+                               return $return;
                        }
 
                        function query($query) {
@@ -28,11 +31,6 @@ if (isset($_GET["mongo"])) {
                        function quote($string) {
                                return $string;
                        }
-
-                       function ping($link) {
-                               $class = 'MongoDB\Driver\Command';
-                               $link->executeCommand('admin', new $class(array('ping' => 1)));
-                       }
                }
 
                class Min_Result {
@@ -397,9 +395,6 @@ if (isset($_GET["mongo"])) {
                        function quote($string) {
                                return $string;
                        }
-
-                       function ping($link) {
-                       }
                }
 
                class Min_Result {
@@ -631,7 +626,7 @@ if (isset($_GET["mongo"])) {
                        if ($password != "") {
                                $options["password"] = "";
                                try {
-                                       $connection->ping($connection->connect("mongodb://$server", $options));
+                                       $connection->connect("mongodb://$server", $options);
                                        return lang('Database does not support password.');
                                } catch (Exception $ex) {
                                        // this is what we want