From 2574ed6bfbc18121608d37d8571ebce7c03eefec Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 27 May 2016 10:20:10 -0500 Subject: [PATCH] Fix session_rel_user table when it does not have the duration field This commit should not be added to 1.11.x and master branches --- main/admin/index.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/admin/index.php b/main/admin/index.php index b54a1d4273..59f110332b 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -438,6 +438,30 @@ if (api_is_platform_admin()) { $blocks = $data['blocks']; } } + + //Hack for fix migration on session_rel_user + $tableColumns = Database::getManager() + ->getConnection() + ->getSchemaManager() + ->listTableColumns( + Database::get_main_table(TABLE_MAIN_SESSION_USER) + ); + + if (!array_key_exists('duration', $tableColumns)) { + try { + $dbSchema = Database::getManager()->getConnection()->getSchemaManager(); + $durationColumn = new \Doctrine\DBAL\Schema\Column( + 'duration', + Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER), + ['notnull' => false] + ); + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]); + $dbSchema->alterTable($tableDiff); + } catch (Exception $e) { + error_log($e->getMessage()); + } + } + //end hack } $admin_ajax_url = api_get_path(WEB_AJAX_PATH) . 'admin.ajax.php';