{"action":"created","issue":{"url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/329","repository_url":"https://api.github.com/repos/mongodb/mongo-php-driver","labels_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/329/labels{/name}","comments_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/329/comments","events_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/329/events","html_url":"https://github.com/mongodb/mongo-php-driver/issues/329","id":156997315,"number":329,"title":"Can't query $cmd collection","user":{"login":"alcaeus","id":383198,"avatar_url":"https://avatars.githubusercontent.com/u/383198?v=3","gravatar_id":"","url":"https://api.github.com/users/alcaeus","html_url":"https://github.com/alcaeus","followers_url":"https://api.github.com/users/alcaeus/followers","following_url":"https://api.github.com/users/alcaeus/following{/other_user}","gists_url":"https://api.github.com/users/alcaeus/gists{/gist_id}","starred_url":"https://api.github.com/users/alcaeus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alcaeus/subscriptions","organizations_url":"https://api.github.com/users/alcaeus/orgs","repos_url":"https://api.github.com/users/alcaeus/repos","events_url":"https://api.github.com/users/alcaeus/events{/privacy}","received_events_url":"https://api.github.com/users/alcaeus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mongodb/mongo-php-driver/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-05-26T14:29:31Z","updated_at":"2016-09-14T20:37:12Z","closed_at":null,"body":"This was previously reported in alcaeus/mongo-php-adapter#110, from the trace I'd assume the error originates in the driver.\r\n\r\nMongoDB exposes a virtual `$cmd` collection that can be used to run database commands. So, the following query is identical to the `currentOp` command:\r\n```\r\n> db.$cmd.sys.inprog.findOne()\r\n{\r\n\t\"inprog\" : [\r\n\t\t{\r\n\t\t\t\"desc\" : \"conn5\",\r\n\t\t\t\"threadId\" : \"0x7000008b1000\",\r\n\t\t\t\"connectionId\" : 5,\r\n\t\t\t\"client\" : \"127.0.0.1:55488\",\r\n\t\t\t\"active\" : true,\r\n\t\t\t\"opid\" : 18107,\r\n\t\t\t\"secs_running\" : 0,\r\n\t\t\t\"microsecs_running\" : NumberLong(24),\r\n\t\t\t\"op\" : \"command\",\r\n\t\t\t\"ns\" : \"admin.$cmd\",\r\n\t\t\t\"query\" : {\r\n\t\t\t\t\"currentOp\" : 1\r\n\t\t\t},\r\n\t\t\t\"numYields\" : 0,\r\n\t\t\t\"locks\" : {\r\n\t\t\t\t\r\n\t\t\t},\r\n\t\t\t\"waitingForLock\" : false,\r\n\t\t\t\"lockStats\" : {\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t],\r\n\t\"ok\" : 1\r\n}\r\n```\r\n\r\nHowever, running this via mongo-php-library will cause a driver exception:\r\n```\r\nphp > $client = new MongoDB\\Client();\r\nphp > $client->selectCollection('admin', '$cmd.sys.inprog')->findOne();\r\nPHP Warning:  Uncaught exception 'MongoDB\\Driver\\Exception\\RuntimeException' with message 'Invalid collection name: admin.$cmd.sys.inprog' in /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php:179\r\nStack trace:\r\n#0 /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php(179): MongoDB\\Driver\\Server->executeQuery('admin.$cmd.sys....', Object(MongoDB\\Driver\\Query), Object(MongoDB\\Driver\\ReadPreference))\r\n#1 /Users/alcaeus/Code/mongo-php-library/src/Operation/FindOne.php(81): MongoDB\\Operation\\Find->execute(Object(MongoDB\\Driver\\Server))\r\n#2 /Users/alcaeus/Code/mongo-php-library/src/Collection.php(468): MongoDB\\Operation\\FindOne->execute(Object(MongoDB\\Driver\\Server))\r\n#3 php shell code(1): MongoDB\\Collection->findOne()\r\n#4 {main}\r\n  thrown in /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php on line 179\r\n\r\nWarning: Uncaught exception 'MongoDB\\Driver\\Exception\\RuntimeException' with message 'Invalid collection name: admin.$cmd.sys.inprog' in /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php:179\r\nStack trace:\r\n#0 /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php(179): MongoDB\\Driver\\Server->executeQuery('admin.$cmd.sys....', Object(MongoDB\\Driver\\Query), Object(MongoDB\\Driver\\ReadPreference))\r\n#1 /Users/alcaeus/Code/mongo-php-library/src/Operation/FindOne.php(81): MongoDB\\Operation\\Find->execute(Object(MongoDB\\Driver\\Server))\r\n#2 /Users/alcaeus/Code/mongo-php-library/src/Collection.php(468): MongoDB\\Operation\\FindOne->execute(Object(MongoDB\\Driver\\Server))\r\n#3 php shell code(1): MongoDB\\Collection->findOne()\r\n#4 {main}\r\n  thrown in /Users/alcaeus/Code/mongo-php-library/src/Operation/Find.php on line 179\r\n```"},"comment":{"url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/comments/247145419","html_url":"https://github.com/mongodb/mongo-php-driver/issues/329#issuecomment-247145419","issue_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/329","id":247145419,"user":{"login":"jmikola","id":244663,"avatar_url":"https://avatars.githubusercontent.com/u/244663?v=3","gravatar_id":"","url":"https://api.github.com/users/jmikola","html_url":"https://github.com/jmikola","followers_url":"https://api.github.com/users/jmikola/followers","following_url":"https://api.github.com/users/jmikola/following{/other_user}","gists_url":"https://api.github.com/users/jmikola/gists{/gist_id}","starred_url":"https://api.github.com/users/jmikola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmikola/subscriptions","organizations_url":"https://api.github.com/users/jmikola/orgs","repos_url":"https://api.github.com/users/jmikola/repos","events_url":"https://api.github.com/users/jmikola/events{/privacy}","received_events_url":"https://api.github.com/users/jmikola/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T20:37:12Z","updated_at":"2016-09-14T20:37:12Z","body":"Note: this may be addressed by [PHPC-783](https://jira.mongodb.org/browse/PHPC-783). I've linked the PHPC JIRA tickets so we can confirm later."}}
{"actor":{"display_login":"jmikola"}}