Просмотр исходного кода

Throw correct exception on empty prefix

Andreas Braun 10 лет назад
Родитель
Сommit
0dc363c131
2 измененных файлов с 4 добавлено и 3 удалено
  1. 1 1
      lib/Mongo/MongoDB.php
  2. 3 2
      lib/Mongo/MongoGridFS.php

+ 1 - 1
lib/Mongo/MongoDB.php

@@ -183,7 +183,7 @@ class MongoDB
      */
     public function getGridFS($prefix = "fs")
     {
-        return new \MongoGridFS($this, $prefix, $prefix);
+        return new \MongoGridFS($this, $prefix);
     }
 
     /**

+ 3 - 2
lib/Mongo/MongoGridFS.php

@@ -55,14 +55,15 @@ class MongoGridFS extends MongoCollection
      * @param string $prefix [optional] <p>Optional collection name prefix.</p>
      * @param mixed $chunks  [optional]
      * @return MongoGridFS
+     * @throws \Exception
      */
     public function __construct(MongoDB $db, $prefix = "fs", $chunks = null)
     {
         if ($chunks) {
-            trigger_error(E_DEPRECATED, "The 'chunks' argument is deprecated and ignored");
+            trigger_error("The 'chunks' argument is deprecated and ignored", E_DEPRECATED);
         }
         if (empty($prefix)) {
-            throw new \InvalidArgumentException('prefix can not be empty');
+            throw new \Exception('MongoGridFS::__construct(): invalid prefix');
         }
 
         $this->database = $db;