Skip to content
This repository was archived by the owner on Feb 20, 2018. It is now read-only.
This repository was archived by the owner on Feb 20, 2018. It is now read-only.

MongoConnectionException doesn't exists for hhvm #46

@ezruneko

Description

@ezruneko

I installed on Ubuntu 14.04LTS MongoDB module in drupal:

curl http://ftp.drupal.org/files/projects/drupal-7.39.tar.gz | tar xvz
curl http://ftp.drupal.org/files/projects/mongodb-7.x-1.x-dev.tar.gz | tar xvz

# hhvm --version
HipHop VM 3.9.1 (rel)
Compiler: tags/HHVM-3.9.1-0-g0f72cfc2f0a01fdfeb72fbcfeb247b72998a66db
Repo schema: 6416960c150a4a4726fda74b659105ded8819d9c

# apt-show-versions hhvm-dev
hhvm-dev:amd64/trusty 3.9.1~trusty uptodate

And crash in line 58 in mongo.module:

\nFatal error: Class undefined: MongoConnectionException in /usr/share/nginx/closure.es/blog/sites/all/modules/mongodb/mongodb.module on line 58
//Line 58 => $mongo = new MongoClient($host, $options);

The snippet code:

    try {
      // Use the 1.3 client if available.
      if (class_exists('MongoClient')) {
        $mongo = new MongoClient($host, $options); //<-- LINE: 58
        // Enable read preference and tags if provided. This can also be
        // controlled on a per query basis at the cursor level if more control
        // is required.
        if (!empty($connection['read_preference'])) {
          $tags = !empty($connection['read_preference']['tags']) ? $connection['read_preference']['tags'] : array();
          $mongo->setReadPreference($connection['read_preference']['preference'], $tags);
        }
      }
      else {
        $mongo = new Mongo($host, $options);
        if (!empty($connection['slave_ok'])) {
          $mongo->setSlaveOkay(TRUE);
        }
      }
      $mongo_objects[$host][$db] = $mongo->selectDB($db);
      $mongo_objects[$host][$db]->connection = $mongo;
    }
    catch (MongoConnectionException $e) {
      $mongo_objects[$host][$db] = new MongoDummy();
      throw $e;
    }

But when i try a simple example like:

<?php

try {
$m = new MongoClient(); // connect
$db = $m->foo; // get the database named "foo"
}
catch (MongoConnectionException $e) {
    print_r($e);
}

?>

Any error is reported in the hhvm/error.log. Bug is generated when hhvm compile the php file because if i add a print_r($host) before $mongo = new MongoClient($host, $options); don't show my print_r()

Another test

<?php

echo 'HHVM version: ' . phpversion() . '<br/>';
echo 'MongoFill version: ' . phpversion('mongo') . '<br/>';
echo '-----------------------------------------<br/>';
echo 'MongoClient: ' . (class_exists('MongoClient') ? 'true' : 'false') . '<br/>';
echo 'MongoConnectionException: ' . (class_exists('MongoConnectionException') ? 'true' : 'false') . '<br/>';
echo 'MongoException: ' . (class_exists('MongoException') ? 'true' : 'false');

?>
//Output:
HHVM version: 5.6.99-hhvm
MongoFill version: 1.4.5
-----------------------------------------
MongoClient: true
MongoConnectionException: false
MongoException: true

Live version: http://closure.es/mongo.php


Updated:

  • I've tried to recompile mongofill-hhvm and redownload from git
  • I've reinstalled Drupal
  • I've tested with 2 versions (dev and stable version) of Mongo Module for Drupal
  • reboot hhvm, nginx and mongo
  • reboot the machine
  • Mongo is up with service --status-all
  • With the mongo command i can add, list and remove dbs

And seems that hhvm dont find the MongoConnectionException class.

  • In my src/ext_mongo.php file the class MongonConnectionException exists
  • But when i use get_declared_classes (); in hhvm dont show the MongoConnection Exception:
    https://gist.github.com/layane/1d7887d0ceb94ee207fe
  • So I confirm that hhvm dont find the MongoConnectionException class
  • I ugly resolve this bug, adding MongoConnectionException.php to my Drupal and importing with require_once();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions