kevin-xw / rock-php

Automatically exported from code.google.com/p/rock-php
0 stars 0 forks source link

Data Import not working #165

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Environment Details:
====================
1- Ubuntu 11.04 32b
2- PHP v5.3.5
3- nginx v1.0.6
4- mongodb-10gen v2.0.0
5- php_mongo 1.2.6
6- rockmongo-v1.1.0

After clicking import it works for like 4,5 seconds and then says that all All 
data has been imported successfully but its not.
The collection is not restored there. I have tried other dumps as well. These 
dumps work fine with mongoimport.
I have also checked permission error and its not.

After failing everything i went to go hardcore debug and modified:
app/controllers/db.php:211
to be like:
        if ($this->isPost()) {
                        if (!empty($_FILES["json"]["tmp_name"])) {
                                $tmp = $_FILES["json"]["tmp_name"];

                                echo '<BR/>';
                                echo '$tmp after assignment';
                                var_dump($tmp);
                                echo '</pre>';
                                echo '<BR/>';

                                echo 'Testing if its a file';
                                echo '<BR/>';
                                echo '<pre>';
                                var_dump(is_file($tmp));
                                echo '</pre>';
                                echo '<BR/>';

                                //read file by it's format
                                $body = "";
                                if (preg_match("/\.gz$/", $_FILES["json"]["name"])) {
                                        $body = gzuncompress(file_get_contents($tmp));
                                }
                                else {
                                        $body = file_get_contents($tmp);
                                        echo '<BR/>';
                                        echo '$body inside else';
                                        echo '<pre>';
                                        var_dump($body);
                                        echo '</pre>';

                                }

                                $ret = $this->_mongo->selectDB($this->db)->execute('function (){ ' . $body . ' }');
                                echo '<BR/>';

                                //read file by it's format
                                $body = "";
                                if (preg_match("/\.gz$/", $_FILES["json"]["name"])) {
                                        $body = gzuncompress(file_get_contents($tmp));
                                }
                                else {
                                        $body = file_get_contents($tmp);
                                        echo '<BR/>';
                                        echo '$body inside else';
                                        echo '<pre>';
                                        var_dump($body);
                                        echo '</pre>';

                                }

                                $ret = $this->_mongo->selectDB($this->db)->execute('function (){ ' . $body . ' }');
                                echo '<BR/>';
                                echo '$body after runing execute';
                                echo '<pre>';
                                var_dump($body);
                                echo '</pre>';
                                echo '<BR/>';
                                echo '$ret after execution';
                                echo '<pre>';
                                var_dump($ret);
                                echo '<BR/>';
                                echo '</pre>';
                                echo '<BR/>';
                                $this->message = "All data import successfully.";
                        }
                        else {
                                $this->error = "Either no file input or file is too large to upload.";
                        }
                }

and here is the output that i got:

$tmp after assignmentstring(14) "/tmp/phphdvBgY" 
Testing if its a file
bool(true)

$body inside else
string(2100) "{ "_id" : { "$oid" : "4e6f4978cce7126b01000032" }, "user_id" : 
"'100000000'", "timestamp" : 1315916152 }
{ "_id" : { "$oid" : "4e72faffcce7127b05000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316158207 }
{ "_id" : { "$oid" : "4e7dc37ecce7121501000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316864894 }
{ "_id" : { "$oid" : "4e7dc4f8cce7121801000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316865272 }
{ "_id" : { "$oid" : "4e7dceb4cce7121901000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316867764 }
{ "_id" : { "$oid" : "4e7dd1e1cce7121501000001" }, "user_id" : "'100000000'", 
"timestamp" : 1316868577 }
{ "_id" : { "$oid" : "4e7dd2a3cce7121601000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316868771 }
{ "_id" : { "$oid" : "4e7dd6f1cce7121901000001" }, "user_id" : "'100000000'", 
"timestamp" : 1316869873 }
{ "_id" : { "$oid" : "4e813e15cce7121701000000" }, "user_id" : "'100000000'", 
"timestamp" : 1317092885 }
{ "_id" : { "$oid" : "4e813f8dcce7121501000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317093261 }
{ "_id" : { "$oid" : "4e814c91cce7121901000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317096593 }
{ "_id" : { "$oid" : "4e814f06cce7121801000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317097222 }
{ "_id" : { "$oid" : "4e814f69cce7121701000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317097321 }
{ "_id" : { "$oid" : "4e82dd69cce7121501000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317199209 }
{ "_id" : { "$oid" : "4e86ca43cce7121601000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317456451 }
{ "_id" : { "$oid" : "4e8974bbcce7121701000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317631163 }
{ "_id" : { "$oid" : "4e897a7ecce7121801000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317632638 }
{ "_id" : { "$oid" : "4e897dfecce7121701000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317633534 }
{ "_id" : { "$oid" : "4e89b83ecce7121901000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317648446 }
{ "_id" : { "$oid" : "4e8aa4b8cce7121601000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317708984 }
"

$body after runing execute
string(2100) "{ "_id" : { "$oid" : "4e6f4978cce7126b01000032" }, "user_id" : 
"'100000000'", "timestamp" : 1315916152 }
{ "_id" : { "$oid" : "4e72faffcce7127b05000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316158207 }
{ "_id" : { "$oid" : "4e7dc37ecce7121501000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316864894 }
{ "_id" : { "$oid" : "4e7dc4f8cce7121801000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316865272 }
{ "_id" : { "$oid" : "4e7dceb4cce7121901000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316867764 }
{ "_id" : { "$oid" : "4e7dd1e1cce7121501000001" }, "user_id" : "'100000000'", 
"timestamp" : 1316868577 }
{ "_id" : { "$oid" : "4e7dd2a3cce7121601000000" }, "user_id" : "'100000000'", 
"timestamp" : 1316868771 }
{ "_id" : { "$oid" : "4e7dd6f1cce7121901000001" }, "user_id" : "'100000000'", 
"timestamp" : 1316869873 }
{ "_id" : { "$oid" : "4e813e15cce7121701000000" }, "user_id" : "'100000000'", 
"timestamp" : 1317092885 }
{ "_id" : { "$oid" : "4e813f8dcce7121501000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317093261 }
{ "_id" : { "$oid" : "4e814c91cce7121901000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317096593 }
{ "_id" : { "$oid" : "4e814f06cce7121801000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317097222 }
{ "_id" : { "$oid" : "4e814f69cce7121701000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317097321 }
{ "_id" : { "$oid" : "4e82dd69cce7121501000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317199209 }
{ "_id" : { "$oid" : "4e86ca43cce7121601000001" }, "user_id" : "'100000000'", 
"timestamp" : 1317456451 }
{ "_id" : { "$oid" : "4e8974bbcce7121701000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317631163 }
{ "_id" : { "$oid" : "4e897a7ecce7121801000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317632638 }
{ "_id" : { "$oid" : "4e897dfecce7121701000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317633534 }
{ "_id" : { "$oid" : "4e89b83ecce7121901000003" }, "user_id" : "'100000000'", 
"timestamp" : 1317648446 }
{ "_id" : { "$oid" : "4e8aa4b8cce7121601000002" }, "user_id" : "'100000000'", 
"timestamp" : 1317708984 }
"

$ret after execution
array(2) {
  ["errmsg"]=>
  string(63) "compile failed: JS Error: SyntaxError: invalid label nofile_b:0"
  ["ok"]=>
  float(0)
}

as you see, something isn't right here. The error here is same for other json 
files i am trying to import. And the most worrying part is that rock-mongo says 
data was imported without any issues.

Here is my config file:
at /home/pmo/public_html/config.php 
<?php
/**
 * RockMongo configuration
 *
 * Defining default options and server configuration
 * @package rockmongo
 */

$MONGO = array();
$MONGO["features"]["log_query"] = "off";//log queries
$MONGO["features"]["theme"] = "default";//theme
$MONGO["features"]["plugins"] = "on";//plugins

$i = 0;

/**
* Configuration of MongoDB servers
* 
* @see more details at http://code.google.com/p/rock-php/wiki/configuration
*/
$MONGO["servers"][$i]["mongo_name"] = "mongodb.domain.com";//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "mongodb.domain.com";//mongo host
$MONGO["servers"][$i]["mongo_port"] = "27017";//mongo port
$MONGO["servers"][$i]["mongo_timeout"] = 30;//mongo connection timeout
//$MONGO["servers"][$i]["mongo_db"] = "MONGO_DATABASE";//default mongo db to 
connect, works only if mongo_auth=false
//$MONGO["servers"][$i]["mongo_user"] = "MONGO_USERNAME";//mongo authentication 
user name, works only if mongo_auth=false
//$MONGO["servers"][$i]["mongo_pass"] = "MONGO_PASSWORD";//mongo authentication 
password, works only if mongo_auth=false
$MONGO["servers"][$i]["mongo_auth"] = true;//enable mongo authentication?

$MONGO["servers"][$i]["control_auth"] = true;//enable control users, works only 
if mongo_auth=false
$MONGO["servers"][$i]["control_users"]["admin"] = "admin";//one of control 
users [USERNAME]=PASSWORD, works only if mongo_auth=false

$MONGO["servers"][$i]["ui_only_dbs"] = "";//databases to display
$MONGO["servers"][$i]["ui_hide_dbs"] = "";//databases to hide
$MONGO["servers"][$i]["ui_hide_collections"] = "";//collections to hide
$MONGO["servers"][$i]["ui_hide_system_collections"] = false;//if hide the 
system collections
$i ++;

/**
 * mini configuration for another mongo server
 */
/**
$MONGO["servers"][$i]["mongo_name"] = "Localhost2";
$MONGO["servers"][$i]["mongo_host"] = "127.0.0.1";
$MONGO["servers"][$i]["mongo_port"] = "27018";
$MONGO["servers"][$i]["control_users"]["admin"] = "admin";
$i ++;
**/

?>

One slight change as you notice would that i am using mongo_auth.

Dump file is attached to this issue.

How to Reproduce:
======================
Install a system with same environment as above.
Download the attached dump.
Select a db from rock-mongo web interface on which logged in user has access.
Try importing file.
Notice the missing collection that should have been created as a successful 
import.
Edit app/controller/db.php as shown above.
Compare results.

Original issue reported on code.google.com by iknewita...@gmail.com on 20 Oct 2011 at 3:11

Attachments:

GoogleCodeExporter commented 9 years ago
I also have this same issue, how did you resolve it with using mongoimport, can 
you import the .js files that are created from rock mongo?

Original comment by SeanCul...@gmail.com on 8 Dec 2011 at 3:34

GoogleCodeExporter commented 9 years ago
Currently, RockMongo can only import the data exported with RockMongo, because 
RockMongo not only import the DATA, also import the INDEXES. But RockMongo will 
support JSON format in next version.

Original comment by iwind....@gmail.com on 4 May 2012 at 6:38

GoogleCodeExporter commented 9 years ago
Fixed in SVN

Original comment by iwind....@gmail.com on 4 May 2012 at 7:16