Exemple #1
0
 public static function updateDatabasePerPatch()
 {
     if (!($patchList = self::getPatchList())) {
         return false;
     }
     ini_set('memory_limit', -1);
     $originalMaxExecutionTime = ini_get('max_execution_time');
     ini_set('max_execution_time', 0);
     SJB_DB::hideMysqlErrors();
     SJB_DB::cleanMysqlErrors();
     $patchList = (include SJB_BASE_DIR . self::UPDATE_DB_FILE);
     $patchFound = false;
     $patchCode = '';
     foreach ($patchList as $patch) {
         if (!$patchCode) {
             $patchCode = $patch;
         } else {
             $patched = SJB_Settings::getValue('db-patch-' . $patchCode);
             if (empty($patched)) {
                 $patch();
                 if (SJB_DB::isErrorExist()) {
                     self::logMysqlErrors($patchCode);
                     $patchFound = 'Can\'t install patch ' . $patchCode;
                 } else {
                     SJB_Settings::addSetting('db-patch-' . $patchCode, 'patched');
                     $patchFound = true;
                 }
                 break;
             }
             $patchCode = '';
         }
     }
     ini_set('max_execution_time', $originalMaxExecutionTime);
     return $patchFound;
 }