Skip to content

Commit

Permalink
Dev Several fixes related to upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 15, 2015
1 parent 68782f6 commit 5bc71ab
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 25 deletions.
4 changes: 4 additions & 0 deletions application/components/AssetManager.php
Expand Up @@ -5,6 +5,10 @@ class AssetManager extends CAssetManager {

public function getBaseUrl() {

/**
* @todo Solve this in a more efficient way, for example by storing the result.
*
*/
return strtr(parent::getBaseUrl(), ['{baseUrl}' => App()->baseUrl]);
}
}
6 changes: 3 additions & 3 deletions application/components/MigrationManager.php
Expand Up @@ -7,7 +7,7 @@
class MigrationManager extends \CApplicationComponent
{
const BASE_MIGRATION='m000000_000000_base';
public $migrationTable = 'tbl_migration';
public $migrationTable = '{{migration}}';
/**
*
* @var string[] The paths to folders containing migrations.
Expand Down Expand Up @@ -54,7 +54,7 @@ protected function getMigrationHistory($limit = -1)

protected function createMigrationHistoryTable()
{
$db=$this->getDbConnection();
$db = App()->db;
echo '<pre>';
echo 'Creating migration history table "'.$this->migrationTable.'"...';
$db->createCommand()->createTable($this->migrationTable,array(
Expand All @@ -74,7 +74,7 @@ public function migrateUp($class)
if ( $class === self::BASE_MIGRATION) {
return;
}
ob_end_flush();
@ob_end_flush();
echo '<pre>';

echo "*** applying $class\n";
Expand Down
9 changes: 5 additions & 4 deletions application/core/WebApplication.php
Expand Up @@ -51,17 +51,18 @@ public function setMaintenanceMode($value) {
@unlink(__DIR__ . '/../config/MAINTENANCE');
}

public function onBeginRequest($event) {
parent::onBeginRequest($event);

public function processRequest()
{
/**
* Add support for maintenance mode.
*/
if ($this->maintenanceMode) {
if ($this->maintenanceMode && strncmp('upgrade', $this->getUrlManager()->parseUrl($this->getRequest()), 7) != 0) {
$this->catchAllRequest = [
'upgrade'
];
}
return true;
return parent::processRequest();
}
public function setSupportedLanguages($value) {
foreach($value as $code => $language) {
Expand Down
Expand Up @@ -31,7 +31,7 @@ public function safeUp()
$translation->model = 'Group'; // We have Single Table Inheritance so we use the base class.
$translation->model_id = $group->id;
foreach ($group->translatableAttributes as $attribute) {
$translation->$attribute = $answer->$attribute;
$translation->$attribute = $group->$attribute;
}
try {
if ($translation->save()) {
Expand Down
15 changes: 0 additions & 15 deletions application/models/QuestionGroup.php
Expand Up @@ -110,21 +110,6 @@ function updateGroupOrder($sid,$lang,$position=0)
}
}

/**
* Insert an array into the groups table
* Returns false if insertion fails, otherwise the new GID
*
* @param array $data array_merge
*/
public function insertRecords($data)
{
$group = new self;
foreach ($data as $k => $v)
$group->$k = $v;
if (!$group->save()) return false;
else return $group->gid;
}

function getGroups($surveyid) {
$language = Survey::model()->findByPk($surveyid)->language;
return Yii::app()->db->createCommand()
Expand Down
5 changes: 4 additions & 1 deletion application/models/Survey.php
Expand Up @@ -23,9 +23,12 @@
*/
class Survey extends LSActiveRecord
{
const FORMAT_GROUP = 'G';
const FORMAT_ALL_IN_ONE = 'A';
const FORMAT_QUESTION = 'S';
private $_fieldMap;
/* Set some setting not by default database */
public $format = 'G';
public $format = self::FORMAT_GROUP;

public function attributeLabels() {
return [
Expand Down
2 changes: 1 addition & 1 deletion application/views/upgrade/database.php
Expand Up @@ -19,7 +19,7 @@
'id' => 'abort',
'url' => App()->createUrl('upgrade/database', ['upgrade' => 'abort']),
'color' => 'danger',
'confirm' => 'Are you sure you wisth to exist maintenance mode? Exiting maintenance mode without finishing database upgrades could result in a degraded user experience.'
'confirm' => 'Are you sure you wish to exist maintenance mode? Exiting maintenance mode without finishing database upgrades could result in a degraded user experience.'
]);
}
?>
Expand Down

0 comments on commit 5bc71ab

Please sign in to comment.