/**
  * Get the serialized Delta
  * 
  * This loads the serialized Delta and calls applyNext() on it 
  * until returns false.
  * 
  * @return null
  */
 public function applyDelta()
 {
     //Check if any of the update process is interrupt state, then rollback to old state
     $deltaRepository = new \Cx\Core_Modules\Update\Model\Repository\DeltaRepository();
     $deltas = $deltaRepository->findAll();
     if (empty($deltas)) {
         return;
     }
     asort($deltas);
     //set the website as Offline mode
     \Cx\Core\Setting\Controller\Setting::init('MultiSite', '', 'FileSystem');
     \Cx\Core\Setting\Controller\Setting::set('websiteState', \Cx\Core_Modules\MultiSite\Model\Entity\Website::STATE_OFFLINE);
     \Cx\Core\Setting\Controller\Setting::update('websiteState');
     $status = true;
     $yamlFile = null;
     foreach ($deltas as $delta) {
         $status = $delta->applyNext();
         $delta->setRollback($delta->getRollback() ? false : true);
         $deltaRepository->flush();
         if (!$status) {
             //Rollback to old state
             $this->rollBackDelta();
             //Rollback the codebase changes(settings.php, configuration.php and website codebase in manager and service)
             $yamlFile = $this->cx->getWebsiteTempPath() . '/Update/' . $this->pendingCodeBaseChangesYml;
             if (file_exists($yamlFile)) {
                 $pendingCodeBaseChanges = $this->getUpdateWebsiteDetailsFromYml($yamlFile);
                 $oldCodeBase = $pendingCodeBaseChanges['PendingCodeBaseChanges']['oldCodeBaseId'];
                 $latestCodeBase = $pendingCodeBaseChanges['PendingCodeBaseChanges']['latestCodeBaseId'];
                 //Register YamlSettingEventListener
                 \Cx\Core\Config\Controller\ComponentController::registerYamlSettingEventListener();
                 //Update codeBase in website
                 $this->updateCodeBase($latestCodeBase, null, $oldCodeBase);
                 //Update website codebase in manager and service
                 \Cx\Core\Setting\Controller\Setting::init('MultiSite', '', 'FileSystem');
                 $websiteName = \Cx\Core\Setting\Controller\Setting::getValue('websiteName', 'MultiSite');
                 $params = array('websiteName' => $websiteName, 'codeBase' => $oldCodeBase);
                 \Cx\Core_Modules\MultiSite\Controller\JsonMultiSiteController::executeCommandOnMyServiceServer('updateWebsiteCodeBase', $params);
             }
             break;
         }
     }
     //Remove the folder '/tmp/Update', After the completion of rollback or Non-rollback process
     $tmpUpdateFolderPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteTempPath() . '/Update';
     if (file_exists($tmpUpdateFolderPath)) {
         \Cx\Lib\FileSystem\FileSystem::delete_folder($tmpUpdateFolderPath, true);
     }
     //set the website back to Online mode
     \Cx\Core\Setting\Controller\Setting::set('websiteState', \Cx\Core_Modules\MultiSite\Model\Entity\Website::STATE_ONLINE);
     \Cx\Core\Setting\Controller\Setting::update('websiteState');
 }
Beispiel #2
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
global $sessionObj, $_CONFIG, $_CORELANG, $objUser, $objDatabase;
if (!isset($objUser) || !isset($objDatabase) || !isset($license)) {
    require_once dirname(dirname(dirname(__FILE__))) . '/core/Core/init.php';
    $cx = init('minimal');
    // In mode 'minimal' we have to manually register event listeners.
    // The listener registerYamlSettingEventListener is used to update the
    // settings.php file.
    \Cx\Core\Config\Controller\ComponentController::registerYamlSettingEventListener();
}
// Init user
if (empty($sessionObj)) {
    $sessionObj = \cmsSession::getInstance();
}
if (!isset($objUser)) {
    $objUser = $cx->getUser()->objUser;
}
$objUser->login();
if (!isset($objDatabase)) {
    $objDatabase = $cx->getDb()->getAdoDb();
}
// update license, return "false" if no connection to license server could be established
if (!isset($license)) {
    $license = $cx->getLicense();