/** * upgrade the module from an old version * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion version number string to upgrade from * @return mixed true on success, last valid version string or false if fails */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': // Rename 'thelang' block. $table = 'blocks'; $sql = "UPDATE {$table} SET bkey = 'lang' WHERE bkey = 'thelang'"; \DBUtil::executeSQL($sql); // Optional upgrade if (in_array(\DBUtil::getLimitedTablename('message'), \DBUtil::metaTables())) { $this->migrateMessages(); } $this->migrateBlockNames(); $this->migrateExtMenu(); case '3.7': case '3.7.0': if (!\DBUtil::changeTable('blocks')) { return false; } case '3.7.1': $this->newBlockPositions(); case '3.8.0': // update empty filter fields to an empty array $entity = $this->name . '\\Entity\\Block'; $dql = "UPDATE {$entity} p SET p.filter = 'a:0:{}' WHERE p.filter = '' OR p.filter = 's:0:\"\";'"; $query = $this->entityManager->createQuery($dql); $query->getResult(); case '3.8.1': // future upgrade routines } // Update successful return true; }
/** * upgrade the module from an old version * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion version number string to upgrade from * @return mixed true on success, last valid version string or false if fails */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': // Rename 'thelang' block. $table = 'blocks'; $sql = "UPDATE {$table} SET bkey = 'lang' WHERE bkey = 'thelang'"; DBUtil::executeSQL($sql); // Optional upgrade if (in_array(DBUtil::getLimitedTablename('message'), DBUtil::metaTables())) { $this->migrateMessages(); } $this->migrateBlockNames(); $this->migrateExtMenu(); case '3.7': case '3.7.0': if (!DBUtil::changeTable('blocks')) { return false; } case '3.7.1': $this->newBlockPositions(); case '3.8.0': // future upgrade routines } // Update successful return true; }
/** * upgrade the module from an old version * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion version number string to upgrade from * @return mixed true on success, last valid version string or false if fails */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': // Rename 'thelang' block. $table = 'blocks'; $sql = "UPDATE $table SET bkey = 'lang' WHERE bkey = 'thelang'"; DBUtil::executeSQL($sql); // Optional upgrade if (in_array(DBUtil::getLimitedTablename('message'), DBUtil::metaTables())) { $this->migrateMessages(); } $this->migrateBlockNames(); $this->migrateExtMenu(); case '3.7': case '3.7.0': if (!DBUtil::changeTable('blocks')) { return false; } case '3.7.1': $this->newBlockPositions(); case '3.8.0': // update empty filter fields to an empty array $entity = $this->name . '_Entity_Block'; $dql = "UPDATE $entity p SET p.filter = 'a:0:{}' WHERE p.filter = '' OR p.filter = 's:0:\"\";' OR p.filter = 'a:3:{s:4:\"type\";s:0:\"\";s:9:\"functions\";s:0:\"\";s:10:\"customargs\";s:0:\"\";}'"; $query = $this->entityManager->createQuery($dql); $query->getResult(); case '3.8.1': // register ui_hooks for HTML block editing HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); case '3.8.2': // future upgrade routines } // Update successful return true; }
/** * Module upgrade */ function mediashare_upgrade($oldVersion) { // Upgrade dependent on old version number switch ($oldVersion) { case '1.0.0': case '1.0.1': if (!mediashare_upgrade_to_1_0_2()) { return '1.0.1'; } case '1.0.2': case '2.0.0': case '2.0.1': case '2.1.0': if (!mediashare_upgrade_to_2_1_1()) { return '2.1.0'; } case '2.1.1': case '2.1.2': if (!mediashare_upgrade_to_2_2_0()) { return '2.1.2'; } case '2.2.0': if (!mediashare_upgrade_to_2_3_0()) { return '2.2.0'; } case '2.3.0': case '3.0.0': case '3.0.1': case '3.1.0': case '3.1.1': case '3.2.0': case '3.3.0': if (!mediashare_upgrade_to_3_4_0()) { return '3.3.0'; } case '3.4.0': if (!mediashare_upgrade_to_3_4_1()) { return '3.4.0'; } case '3.4.1': mediashare_upgrade_to_3_4_2(); case '3.4.2': case '4.0.0': case '4.0.1': $tables = DBUtil::metaTables(); $ptable = DBUtil::getLimitedTablename('mediashare_photoshare'); if (in_array($ptable, $tables) && !DBUtil::dropTable('mediashare_photoshare')) { return '4.0.1'; } case '4.0.2': case '4.1': // future } // Update successful return true; }