From 8f7360b8ce926a2126d2a75a505bbe9d36d62e25 Mon Sep 17 00:00:00 2001 From: Charles Severance Date: Fri, 5 Feb 2021 09:51:57 -0500 Subject: [PATCH] Updates to make bootstrapping easier. --- admin/gate.php | 12 +++++++++++- admin/index.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/admin/gate.php b/admin/gate.php index 76de8ab273..c85476e130 100644 --- a/admin/gate.php +++ b/admin/gate.php @@ -13,7 +13,17 @@ die('Please set $CFG->adminpw to a plaintext or hashed string'); } -if ( $CFG->google_client_id && ! U::get($_SESSION,'id') ) { +// Make sure we have an initialized database before sending to login.php +try { + define('PDO_WILL_CATCH', true); + $PDOX = \Tsugi\Core\LTIX::getConnection(); + $stmt = $PDOX->queryReturnError("SELECT key_id FROM {$CFG->dbprefix}lti_key LIMIT 1"); + $havedatabase = $stmt->success; +} catch(\PDOException $ex){ + $havedatabase = false; +} + +if ( $havedatabase && $CFG->google_client_id && ! U::get($_SESSION,'id') ) { $_SESSION['login_return'] = $rest_path->full; Output::doRedirect($CFG->wwwroot.'/login.php'); return; diff --git a/admin/index.php b/admin/index.php index 0c5a371cc0..b3bc7e31af 100644 --- a/admin/index.php +++ b/admin/index.php @@ -10,7 +10,7 @@ require_once("sanity.php"); $PDOX = false; try { - define('PDO_WILL_CATCH', true); + if ( ! defined('PDO_WILL_CATCH') ) define('PDO_WILL_CATCH', true); $PDOX = \Tsugi\Core\LTIX::getConnection(); } catch(\PDOException $ex){ $PDOX = false; // sanity-db-will re-check this below