Skip to content

Commit

Permalink
for PHP 7, use alcaeus/mongo-php-adapter compatibility layer and mong…
Browse files Browse the repository at this point in the history
…odb extension
  • Loading branch information
remicollet committed Jun 16, 2016
1 parent 2d4faa0 commit 3661871
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions framework/Cache/test/Horde/Cache/MongoTest.php
Expand Up @@ -23,8 +23,8 @@ class Horde_Cache_MongoTest extends Horde_Cache_TestBase
{
protected function _getCache($params = array())
{
if (!extension_loaded('mongo')) {
$this->reason = 'Mongo extension not loaded';
if (!extension_loaded('mongo') && !extension_loaded('mongodb')) {
$this->reason = 'Mongo/Mongodb extensions not loaded';
return;
}
if (!class_exists('Horde_Mongo_Client')) {
Expand Down
5 changes: 5 additions & 0 deletions framework/Mongo/bundle/composer.json
@@ -0,0 +1,5 @@
{
"require": {
"alcaeus/mongo-php-adapter": "^1.0.3"
}
}
9 changes: 9 additions & 0 deletions framework/Mongo/lib/Horde/Mongo/Client.php
Expand Up @@ -11,6 +11,15 @@
* @package Mongo
*/

if (!extension_loaded('mongo')) {
// use the compatibility layer and mongodb extension
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php'; // PEAR installation
} else {
require_once __DIR__ . '/../../../bundle/vendor/autoload.php'; // GIT
}
}

/**
* Extend the base PECL MongoClient class by allowing it to be serialized.
*
Expand Down
2 changes: 1 addition & 1 deletion framework/Test/lib/Horde/Test/Factory/Mongo.php
Expand Up @@ -41,7 +41,7 @@ public function create(array $params = array())
{
$mongo = null;

if (extension_loaded('mongo') &&
if ((extension_loaded('mongo') || extension_loaded('mongodb')) &&
class_exists('Horde_Mongo_Client') &&
!empty($params['config'])) {
try {
Expand Down

0 comments on commit 3661871

Please sign in to comment.