public function actionRun() { $this->forcePostRequest(); $updatePackage = OnlineUpdateAPI::getAvailableUpdate(); if ($updatePackage === null) { return $this->redirect($this->createUrl('index')); } $warnings = $updatePackage->install(); $migration = ""; Yii::import('application.commands.shell.HUpdateCommand'); if (class_exists('HUpdateCommand') && method_exists('HUpdateCommand', 'AutoUpdate')) { $migration = HUpdateCommand::AutoUpdate(); } else { // Old way Yii::import('application.commands.shell.ZMigrateCommand'); $migration = ZMigrateCommand::AutoMigrate(); } Yii::app()->cache->flush(); ModuleManager::flushCache(); $this->render('run', array('updatePackage' => $updatePackage, 'warnings' => $warnings, 'migration' => $migration)); }
/** * This method is called after an update is performed. * You may extend it with your own update process. * */ public function update() { // Auto Migrate (add module database changes) Yii::import('application.commands.shell.ZMigrateCommand'); $migrate = ZMigrateCommand::AutoMigrate(); }
<?php Yii::app()->params['installed'] = false; // Migrate up the database Yii::import('application.commands.shell.ZMigrateCommand'); ZMigrateCommand::AutoMigrate(); Yii::app()->params['installed'] = true; // Create empty dynamic configuration file $content = "<" . "?php return "; $content .= var_export(array(), true); $content .= "; ?" . ">"; file_put_contents(Yii::app()->params['dynamicConfigFile'], $content); foreach ($this->getFixtures() as $tableName => $fixturePath) { $this->resetTable($tableName); $this->loadFixture($tableName); } // initialize a controller (which defaults to null in tests) $c = new CController('phpunit'); $c->setAction(new CInlineAction($c, 'urltest')); Yii::app()->setController($c); // Add Categories $cGeneral = new ProfileFieldCategory(); $cGeneral->title = "General"; $cGeneral->sort_order = 100; $cGeneral->visibility = 1; $cGeneral->is_system = true; $cGeneral->description = ''; $cGeneral->save(); $cCommunication = new ProfileFieldCategory(); $cCommunication->title = "Communication"; $cCommunication->sort_order = 200;
/** * Self Test */ public function actionSelfTest() { Yii::import('application.commands.shell.ZMigrateCommand'); $migrate = ZMigrateCommand::AutoMigrate(); $this->render('selftest', array('checks' => SelfTest::getResults(), 'migrate' => $migrate)); }
/** * Lists all installed modules. * * @param array $args */ public function actionIndex($args) { print "Checking for new updates..."; $updatePackage = OnlineUpdateAPI::getAvailableUpdate(); print "OK\n\n"; if ($updatePackage == null) { print "No new update available!\n\n"; return; } print "Update to " . $updatePackage->versionTo . " found!\n"; print "\n"; echo Yii::t('UpdaterModule.base', 'Please note:') . "\n"; echo "\t - " . Yii::t('UpdaterModule.base', 'Backup all your files & database before proceed') . "\n"; echo "\t - " . Yii::t('UpdaterModule.base', 'Make sure all files are writable by application') . "\n"; echo "\t - " . Yii::t('UpdaterModule.base', 'Please update installed marketplace modules before and after the update') . "\n"; echo "\t - " . Yii::t('UpdaterModule.base', 'Make sure custom modules or themes are compatible with version %version%', array('%version%' => $updatePackage->versionTo)) . "\n"; echo "\t - " . Yii::t('UpdaterModule.base', 'Do not use this updater in combination with Git!') . "\n"; echo "\n"; if (!$this->confirm("Proceed?", true)) { print "Aborted!\n"; return; } print "\n"; print "Downloading update package..."; $updatePackage->download(); print "OK!\n"; print "Extracting update package..."; $updatePackage->extract(); print "OK!\n"; print "Validating package..."; $validationResults = $updatePackage->validate(); print "OK!\n"; print "\n"; if (count($validationResults['notWritable']) != 0) { print "ERROR!\n"; print "Following files are not writable: \n"; foreach ($validationResults['notWritable'] as $file) { print "\t - " . $file . "\n"; } print "\n"; print "Please make this files writable and restart.\n\n"; return; } if (count($validationResults['modified']) != 0) { echo Yii::t('UpdaterModule.base', 'The following files seems to be not original (%version%) and will be overwritten or deleted during update process.', array('%version%' => $updatePackage->versionFrom)) . "\n"; foreach ($validationResults['modified'] as $file) { print "\t - " . $file . "\n"; } if (!$this->confirm("These file(s) will be overwritten during update. OK?", true)) { print "Aborted!\n"; return; } print "\n"; } print "\n"; print "RELEASE NOTES:\n\n"; print $updatePackage->getReleaseNotes(); print "\n\n"; if (!$this->confirm("Proceed?", true)) { print "Aborted!\n"; return; } print "\n"; print "Installing..."; $warnings = $updatePackage->install(); print "OK!\n"; if (count($warnings) != 0) { print "\n"; print "WARNINGS:\n"; foreach ($warnings as $warning) { print "\t - " . $warning . "\n"; } } print "Migrating DB..."; $migration = ""; Yii::import('application.commands.shell.HUpdateCommand'); if (class_exists('HUpdateCommand') && method_exists('HUpdateCommand', 'AutoUpdate')) { $migration = HUpdateCommand::AutoUpdate(); } else { // Old way Yii::import('application.commands.shell.ZMigrateCommand'); $migration = ZMigrateCommand::AutoMigrate(); } print "OK!\n"; if ($this->confirm("Show migration results?", false)) { print $migration . "\n"; } Yii::app()->cache->flush(); ModuleManager::flushCache(); print "\n\n*** Updater successfully finished! ***\n\n"; if ($this->confirm("Check for new/next available update?", true)) { print "\n\n------------------------------- \n\n\n"; return $this->actionIndex($args); } }
/** * The init action imports the database structure & inital data */ public function actionInit() { if (!$this->getModule()->checkDBConnection()) { $this->redirect(Yii::app()->createUrl('//installer/setup/database')); } // Flush Caches Yii::app()->cache->flush(); // Disable max execution time to avoid timeouts during database installation @ini_set('max_execution_time', 0); // Migrate Up Database Yii::import('application.commands.shell.ZMigrateCommand'); ZMigrateCommand::AutoMigrate(); $this->redirect(Yii::app()->createUrl('//installer/config/index')); }