Skip to content

Commit

Permalink
Fixed issue #19351: Limesurvey broken after 5.6.50 to 6.4.2 upgrade (#…
Browse files Browse the repository at this point in the history
…3713)

Co-authored-by: Denis Chenu <denis@sondages.pro>
  • Loading branch information
mohabmes and Shnoulle committed Feb 2, 2024
1 parent 3723fee commit 823e621
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion application/config/version.php
Expand Up @@ -11,8 +11,9 @@
* See COPYRIGHT.php for copyright notices and details.
*/


$config['versionnumber'] = '6.4.4';
$config['dbversionnumber'] = 622;
$config['dbversionnumber'] = 623;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/update/updates/Update_619.php
Expand Up @@ -11,6 +11,6 @@ class Update_619 extends DatabaseUpdateBase
*/
public function up()
{
$this->db->createCommand()->addColumn('{{users}}', 'user_status', 'BOOLEAN DEFAULT TRUE');
$this->db->createCommand()->addColumn('{{users}}', 'user_status', 'integer DEFAULT 1');
}
}
23 changes: 23 additions & 0 deletions application/helpers/update/updates/Update_623.php
@@ -0,0 +1,23 @@
<?php

namespace LimeSurvey\Helpers\Update;

use LimeSurvey\Helpers\Update\DatabaseUpdateBase;

class Update_623 extends DatabaseUpdateBase
{
/**
* @inheritDoc
*/
public function up()
{
if (\Yii::app()->db->driverName == 'pgsql') {
$table = \Yii::app()->db->schema->getTable('{{users}}');
if (isset($table->columns['user_status']) && $table->columns['user_status']->dbType != 'integer') {
$this->db->createCommand("ALTER TABLE {{users}} ALTER COLUMN user_status DROP DEFAULT;")->execute();
$this->db->createCommand("ALTER TABLE {{users}} ALTER COLUMN user_status TYPE INT USING CASE WHEN user_status=TRUE THEN 1 ELSE 0 END;")->execute();
$this->db->createCommand("ALTER TABLE {{users}} ALTER COLUMN user_status SET DEFAULT 1;")->execute();
}
}
}
}
3 changes: 2 additions & 1 deletion application/models/User.php
Expand Up @@ -132,10 +132,11 @@ public function rules()
/** @inheritdoc */
public function scopes()
{
$userStatusType = \Yii::app()->db->schema->getTable('{{users}}')->columns['user_status']->dbType;
$activeScope = array(
'condition' => 'user_status = :active',
'params' => array(
'active' => 1,
'active' => $userStatusType == 'boolean' ? 'TRUE' : '1',
)
);

Expand Down

0 comments on commit 823e621

Please sign in to comment.