magento migration script and php7 an bitnami mamp

Hi there,
we tried your data migration tool on a bitmami mamp stack with php7.
Magento runs prefect here but after the first step of your script we get an error.
Pls see error code below.
 
Any idea what happens here?
Thank you,
 
André
 
 
 
Error
Call to undefined function mysql_connect()

/Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/protected/controllers/MigrateController.php(110)

098     /**
099      * Database settings
100      */
101     public function actionStep1()
102     {
103         $step = MigrateSteps::model()->find("sorder = 1");
104         if (Yii::app()->request->isPostRequest){
105 
106             $step->migrated_data = json_encode($_POST);
107 
108             //validate database
109             $err_msg = array();
110             $validate = @mysql_connect($_POST['mg1_host'], $_POST['mg1_db_user'], $_POST['mg1_db_pass']);
111             if (!$validate){
112                 $err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 1 database.");
113             }else{
114                 if (!mysql_select_db( $_POST['mg1_db_name'], $validate)){
115                     $err_msg[] = Yii::t('frontend', "Database Name of Magento 1 was not found in database.");
116                     $validate = false;
117                 }else{
118                     //validate magento2
119                     mysql_close($validate);
120                     $validate = @mysql_connect($_POST['mg2_host'], $_POST['mg2_db_user'], $_POST['mg2_db_pass']);
121                     if (!$validate){
122                         $err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 2 database.");

Stack Trace

#0

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/actions/CInlineAction.php(49): MigrateController->actionStep1()
 

#1

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/CController.php(308): CInlineAction->runWithParams(array())
 

#2

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/CController.php(286): CController->runAction(CInlineAction)
 

#3

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array())
 

#4

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/CWebApplication.php(282): CController->run(“step1”)
 

#5

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/web/CWebApplication.php(141): CWebApplication->runController(“migrate/step1”)
 

#6

+
  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/base/CApplication.php(184): CWebApplication->processRequest()
 

#7


  /Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/index.php(13): CApplication->run()

08 
09 //remove the following line when in production mode
10 defined('YII_DEBUG') or define('YII_DEBUG', true);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();

4 answers

Profile photo of Mall Staff 184060.00 $tone December 6, 2015
Public

Hi andre ulrich,
That issue because the function ‘mysql_connect’ was removed in PHP7. (http://prntscr.com/9av2ly)
To solve that, you can do as bellow:
Open the file at /protected/controllers/MigrateController.php
and find to the block code (line 110 -> 132):

$validate = @mysql_connect($_POST['mg1_host'], $_POST['mg1_db_user'], $_POST['mg1_db_pass']);
if (!$validate){
$err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 1 database.");
}else{
if (!mysql_select_db( $_POST['mg1_db_name'], $validate)){
$err_msg[] = Yii::t('frontend', "Database Name of Magento 1 was not found in database.");
$validate = false;
}else{
//validate magento2
mysql_close($validate);
$validate = @mysql_connect($_POST['mg2_host'], $_POST['mg2_db_user'], $_POST['mg2_db_pass']);
if (!$validate){
$err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 2 database.");
}else{
if (!mysql_select_db( $_POST['mg2_db_name'], $validate)){
$err_msg[] = Yii::t('frontend', "Database Name of Magento 2 was not found in database.");
$validate = false;
} else{
mysql_close($validate);
}
}
}
}

and replace it by block code:

$validate = mysqli_connect($_POST['mg1_host'], $_POST['mg1_db_user'], $_POST['mg1_db_pass'], $_POST['mg1_db_name']);
if (!$validate){
$err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 1 database.");
}else{
mysqli_close($validate);
//validate magento2
$validate = mysqli_connect($_POST['mg2_host'], $_POST['mg2_db_user'], $_POST['mg2_db_pass'], $_POST['mg2_db_name']);
if (!$validate){
$err_msg[] = Yii::t('frontend', "Couldn't connected to Magento 2 database.");
}else{
mysqli_close($validate);
}
}

Let’s do it to solve the issue as you said with PHP 7.
(The PHP 7 was not stable at this time, and you shouldn’t use it now.)
Regards,
Mall.

#1
Profile photo of andre ulrich 250.00 $tone December 6, 2015
Public

Hi there,
many thanks!
We just tried it and now get this error:
 
Application runtime path “/Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/protected/runtime” is not valid. Please make sure it is a directory writable by the Web server process.

/Applications/mampstack-7.0.0-0/apache2/htdocs/migrate-data-tool/yii/base/CApplication.php(293)

281             return $this->_runtimePath;
282         }
283     }
284 
285     /**
286      * Sets the directory that stores runtime files.
287      * @param string $path the directory that stores runtime files.
288      * @throws CException if the directory does not exist or is not writable
289      */
290     public function setRuntimePath($path)
291     {
292         if(($runtimePath=realpath($path))===false || !is_dir($runtimePath) || !is_writable($runtimePath))
293             throw new CException(Yii::t('yii','Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.',
294                 array('{path}'=>$path)));
295         $this->_runtimePath=$runtimePath;
296     }
297 
298     /**
299      * Returns the root directory that holds all third-party extensions.
300      * @return string the directory that contains all extensions. Defaults to the 'extensions' directory under 'protected'.
301      */
302     public function getExtensionPath()
303     {
304         return Yii::getPathOfAlias('ext');
305     }
#2
Profile photo of andre ulrich 250.00 $tone December 6, 2015
Public

We also have a problem finden the path your described for reindexing:
————-
PATH_TO_YOUR_WEB_ROOT_FOLDER\your_magento2_folder\dev\shell\ 
and type in the command line: php indexer.php reindexall then press enter key to re-index all data in your Magento 2 website.
————-
We do not have a folder called shell under dev. Can you let us know how to reindex with a mamp installation on a mac?
Many thanks again!

#3

Please login or Register to Submit Answer

Written By

Comments