Просмотр исходного кода

Merge branch 'master' of https://github.com/unacms/una

AntonLV 2 лет назад
Родитель
Сommit
dc4aa32deb
1 измененных файлов с 16 добавлено и 6 удалено
  1. 16 6
      inc/classes/BxDolUpgrader.php

+ 16 - 6
inc/classes/BxDolUpgrader.php

@@ -11,6 +11,7 @@ class BxDolUpgrader extends BxDol
 {
     protected $_sUrlVersionCheck = 'https://v.unacms.com/';
     protected $_sError = false;
+    protected $oDb = null;
 
     /**
      * Prepare for system upgrade.
@@ -20,16 +21,13 @@ class BxDolUpgrader extends BxDol
      */
     public function prepare($bAuto = true)
     {
+        $this->oDb = BxDolDb::getInstance(); // to use in check.php file 
         $this->setError(false);
         $iUmaskSave = umask(0);
 
         while(true) {
 
-            /**
-             * 
-             * NOTE. Temporary disabled.
-             * TODO. Enable after "Main Version Compatibility Check" will be performed for updates.
-             * 
+            // check for modules updates before system update
             if(!$bAuto) {
                 $aUpdates = BxDolStudioInstallerUtils::getInstance()->checkUpdates();
                 if(!empty($aUpdates) && is_array($aUpdates)) {
@@ -37,7 +35,6 @@ class BxDolUpgrader extends BxDol
                     break;
                 }
             }
-             */
 
             $aVersionUpdateInfo = $this->getVersionUpdateInfo();
             if (null === $aVersionUpdateInfo) {
@@ -90,6 +87,12 @@ class BxDolUpgrader extends BxDol
                 break;
             }
 
+            if (true !== ($sError = $this->performCheck ($sUnpackedPath, $aVersionUpdateInfo))) {
+                $this->deleteUpgradeFolder($sPatchPath);
+                $this->setError($sError);
+                break;
+            }
+
             if (!$this->setTransientUpgradeCronJob ($sUnpackedPath)) {
                 $this->deleteUpgradeFolder($sPatchPath);
                 $this->setError(_t('_sys_upgrade_set_cron_failed'));
@@ -200,6 +203,13 @@ class BxDolUpgrader extends BxDol
         return file_exists($sCheckFilePath) && file_exists($sVersionFilePath) && file_exists($sUnpackedPath . 'BxDolUpgradeCron.php');
     }
 
+    protected function performCheck ($sUnpackedPath, $aVersionUpdateInfo)
+    {
+        $sPath = $sUnpackedPath . 'files/' . $this->normalizeVersion(bx_get_ver()) . '-' . $this->normalizeVersion($aVersionUpdateInfo['patch']['ver']) . '/';
+        $sCheckFilePath =  $sPath . 'check.php';
+        return include ($sCheckFilePath);
+    }
+
     public function setTransientUpgradeCronJob ($sUnpackedPath)
     {
         $sUnpackedPath = rtrim($sUnpackedPath, '/') . '/';