| Conditions | 21 |
| Paths | > 20000 |
| Total Lines | 153 |
| Code Lines | 101 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 54 | */ |
||
| 55 | function xoops_module_update_wggithub($module, $prev_version = null) |
||
| 56 | {
|
||
| 57 | require \dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 58 | |||
| 59 | $moduleDirName = $module->dirname(); |
||
| 60 | |||
| 61 | //wggithub_check_db($module); |
||
| 62 | |||
| 63 | //check upload directory |
||
| 64 | include_once __DIR__ . '/install.php'; |
||
| 65 | xoops_module_install_wggithub($module); |
||
| 66 | |||
| 67 | // update DB corresponding to sql/mysql.sql |
||
| 68 | $configurator = new Configurator(); |
||
| 69 | $migrate = new Migrate($configurator); |
||
| 70 | |||
| 71 | $fileSql = \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/sql/mysql.sql'; |
||
| 72 | // ToDo: add function setDefinitionFile to .\class\libraries\vendor\xoops\xmf\src\Database\Migrate.php |
||
| 73 | // Todo: once we are using setDefinitionFile this part has to be adapted |
||
| 74 | //$fileYaml = \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/sql/update_' . $moduleDirName . '_migrate.yml'; |
||
| 75 | //try {
|
||
| 76 | //$migrate->setDefinitionFile('update_' . $moduleDirName);
|
||
| 77 | //} catch (\Exception $e) {
|
||
| 78 | // as long as this is not done default file has to be created |
||
| 79 | $moduleVersion = $module->getInfo('version');
|
||
| 80 | $fileYaml = \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . "/sql/{$moduleDirName}_{$moduleVersion}_migrate.yml";
|
||
| 81 | //} |
||
| 82 | |||
| 83 | // create a schema file based on sql/mysql.sql |
||
| 84 | $migratehelper = new MigrateHelper($fileSql, $fileYaml); |
||
| 85 | if (!$migratehelper->createSchemaFromSqlfile()) {
|
||
| 86 | \xoops_error('Error: creation schema file failed!');
|
||
| 87 | return false; |
||
| 88 | } |
||
| 89 | |||
| 90 | // run standard procedure for db migration |
||
| 91 | $migrate->synchronizeSchema(); |
||
| 92 | |||
| 93 | $errors = $module->getErrors(); |
||
| 94 | if (!empty($errors)) {
|
||
| 95 | print_r($errors); |
||
| 96 | } |
||
| 97 | |||
| 98 | return true; |
||
| 99 | |||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param $module |
||
| 104 | * |
||
| 105 | * @return bool |
||
| 106 | */ |
||
| 107 | /* |
||
| 108 | function wggithub_check_db($module) |
||
| 109 | {
|
||
| 110 | $ret = true; |
||
| 111 | //insert here code for database check |
||
| 112 | |||
| 113 | return $ret; |
||
| 114 | } |
||
| 115 | */ |
||
| 116 |