Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-277

Dropping a non-existent database throws an exception when authorization is on

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.2.0-alpha1
    • Component/s: None
    • None
    • Environment:
      Debian 8
      MongoDB 3.4.6

      The DropCollection class is set to noop if the collection does not exist here:

      https://github.com/mongodb/mongo-php-library/blob/master/src/Operation/DropCollection.php#L95

      This will work if authorization: disabled, however, when it is enabled the error is:

       not authorized on db_name to execute command { drop: "does_not_exist_coll" }
      

      and so DropCollection will throw the error.

      This comes up when using Doctrine's MongoDBPurger

      Stack trace:

       () at ./vendor/mongodb/mongodb/src/Operation/DropCollection.php:93
       MongoDB\Driver\Server->executeCommand() at ./vendor/mongodb/mongodb/src/Operation/DropCollection.php:93
       MongoDB\Operation\DropCollection->execute() at ./vendor/mongodb/mongodb/src/Collection.php:431
       MongoDB\Collection->drop() at ./vendor/alcaeus/mongo-php-adapter/lib/Mongo/MongoCollection.php:247
       MongoCollection->drop() at ./vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Collection.php:1102
       Doctrine\MongoDB\Collection->doDrop() at ./vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Collection.php:297
       Doctrine\MongoDB\Collection->drop() at ./vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Purger/MongoDBPurger.php:70
       Doctrine\Common\DataFixtures\Purger\MongoDBPurger->purge() at ./src/Ei/GlowSvc/Infrastructure/InfrastructureBundle/Command/PurgeAllODMCommand.php:49
       Ei\GlowSvc\Infrastructure\InfrastructureBundle\Command\PurgeAllODMCommand->execute() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:264
       Symfony\Component\Console\Command\Command->run() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:887
       Symfony\Component\Console\Application->doRunCommand() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:223
       Symfony\Component\Console\Application->doRun() at ./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:81
       Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:130
      

      Ideally the upstream code would not attempt to drop non-existent collections. I may place a ticket in doctrine as well and cross-ref.

            Assignee:
            Unassigned Unassigned
            Reporter:
            douglas.reith@engagementinnovation.com Douglas Reith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: