From 278dc0f7a5fcdca84126323001f42fa3f5f366d8 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Wed, 20 Dec 2017 14:37:08 -0500 Subject: [PATCH 1/7] Added mobile message to unscannable suggestion. Fixes #216 --- config/localConfig.template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/localConfig.template.php b/config/localConfig.template.php index 0189b2193..bcc51099c 100755 --- a/config/localConfig.template.php +++ b/config/localConfig.template.php @@ -13,7 +13,7 @@ $doc_length = '1500'; /* Unscannable Suggestion */ -$unscannable_suggestion = 'Consider converting these documents to Pages, since they are easier to update and generally more accessible.'; +$unscannable_suggestion = 'Consider converting these documents to Pages, since they are easier to update, easier to view on mobile devices, and generally more accessible.'; $unscannable_suggestion_on = true; /* Tool name for display in Canvas Navigation */ From 04e43007e1820afb6622e8e6dda3efe45bbfa039 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 25 Jan 2018 17:25:12 -0500 Subject: [PATCH 2/7] changed parameter to and tested --- config/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings.php b/config/settings.php index 7017ad10e..b756419cf 100755 --- a/config/settings.php +++ b/config/settings.php @@ -32,7 +32,7 @@ isset($UDOIT_ENV) || $UDOIT_ENV = ENV_PROD; // !! override in your localConfig.php // SET UP OAUTH -UdoitUtils::setupOauth($oauth2_id, $oauth2_key, $oauth2_id, $consumer_key, $shared_secret); +UdoitUtils::setupOauth($oauth2_id, $oauth2_key, $oauth2_uri, $consumer_key, $shared_secret); // SET UP DATABASE UdoitDB::setup($db_type, $dsn, $db_user, $db_password); From 9e0dd99570321b568628579454c35f8713714c3c Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 8 Feb 2018 17:58:23 -0500 Subject: [PATCH 3/7] Applied migration fixes as suggested by Santa Rosa Junior College --- migrations/001_move_reports_to_db.php | 9 +++++++-- migrations/002_add_background_queue.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/migrations/001_move_reports_to_db.php b/migrations/001_move_reports_to_db.php index b4c25ee0f..85d61f318 100644 --- a/migrations/001_move_reports_to_db.php +++ b/migrations/001_move_reports_to_db.php @@ -51,10 +51,10 @@ } // add the column if it's missing -if ($check_for_column($db_reports_table, $col_to_add)) { +if (!$check_for_column($db_reports_table, $col_to_add)) { // Quick hack to add report column since we dont have migrations yet $column_type = $db_type == 'mysql' ? 'MEDIUMTEXT' : 'TEXT'; - $dbh->query("ALTER TABLE {$db_reports_table} ADD {$col_to_add} {$column_type}"); + UdoitDB::query("ALTER TABLE {$db_reports_table} ADD {$col_to_add} {$column_type}"); } // exit with warning if the column is still missing @@ -66,6 +66,11 @@ return; } +// Grab all rows from the reports table +if ($rows = UdoidDB::query('SELECT * FROM reports')) { + $rows = $rows->fetchAll(); +} + // now move the reports from the report files into the database $sth = UdoitDB::prepare("UPDATE {$db_reports_table} set {$col_to_add} = :report_json WHERE id = :id"); $count_moved = 0; diff --git a/migrations/002_add_background_queue.php b/migrations/002_add_background_queue.php index fbcec4e97..866cc8ab2 100644 --- a/migrations/002_add_background_queue.php +++ b/migrations/002_add_background_queue.php @@ -52,7 +52,7 @@ `user_id` int(10) unsigned NOT NULL, `job_type` varchar(255) NOT NULL, `data` text, - `results` text, + `results` mediumtext, `status` varchar(255) NOT NULL DEFAULT "new", `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_completed` timestamp, From a40eace34dc899c0b439e72ebb69d70dd8de0860 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 15 Feb 2018 16:07:28 -0500 Subject: [PATCH 4/7] Empty canvas_url fields now update automatically. We'll have to figure out how to deal with the same user id from multiple instances of Canvas in the future --- lib/UdoitUtils.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/UdoitUtils.php b/lib/UdoitUtils.php index dc89e32d1..021471085 100644 --- a/lib/UdoitUtils.php +++ b/lib/UdoitUtils.php @@ -90,10 +90,14 @@ public function getLocalApiKey($user_id) $sth = UdoitDB::prepare("SELECT api_key, canvas_url FROM {$db_user_table} WHERE id = :userid LIMIT 1"); $sth->bindValue(':userid', $user_id, PDO::PARAM_INT); $sth->execute(); - if ($result = $sth->fetchObject()) { - self::$canvas_base_url = $result->canvas_url; - return $result->api_key; + if ($result = $sth->fetchObject()) { + if (empty($result->canvas_url)) { + return false; + } else { + self::$canvas_base_url = $result->canvas_url; + return $result->api_key; + } } return false; @@ -209,11 +213,13 @@ public function createOrUpdateUser($user_id, $api_key, $refresh_token, $canvas_u { global $db_user_table; - $sth = UdoitDB::prepare("SELECT * FROM {$db_user_table} WHERE id = :userid AND canvas_url = :canvas_url LIMIT 1"); + // Try to find the user first + // Note: We're not looking for a matching Canvas URL because the id field is unique + $sth = UdoitDB::prepare("SELECT * FROM {$db_user_table} WHERE id = :userid LIMIT 1"); $sth->bindValue(':userid', $user_id, PDO::PARAM_INT); - $sth->bindValue(':canvas_url', $canvas_url, PDO::PARAM_STR); $sth->execute(); + // If we found the user, update them. Otherwise, insert a new one. if ($result = $sth->fetchObject()) { $sth = UdoitDB::prepare("UPDATE {$db_user_table} SET api_key = :api_key, refresh_token = :refresh_token, canvas_url = :canvas_url WHERE id = :userid"); } else { From ffbadc3e5e4d2f6229bb7502a146d895e699cb17 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 15 Feb 2018 16:33:55 -0500 Subject: [PATCH 5/7] Changed version number, added empty checks for scan results and table headers --- config/settings.php | 2 +- lib/UdoitJob.php | 12 ++++++++++-- lib/quail/quail/common/accessibility_tests.php | 14 ++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/config/settings.php b/config/settings.php index b756419cf..0113fa945 100755 --- a/config/settings.php +++ b/config/settings.php @@ -2,7 +2,7 @@ define('ENV_TEST', 'test'); define('ENV_PROD', 'prod'); define('ENV_DEV', 'dev'); -define('UDOIT_VERSION', '2.3.0'); +define('UDOIT_VERSION', '2.3.1'); // SET UP AUTOLOADER (uses autoload rules from composer) require_once(__DIR__.'/../vendor/autoload.php'); diff --git a/lib/UdoitJob.php b/lib/UdoitJob.php index 543ae5cb4..3736a94be 100644 --- a/lib/UdoitJob.php +++ b/lib/UdoitJob.php @@ -167,9 +167,10 @@ protected static function finalizeReport($job_group, $job_data) protected static function combineJobResults($job_group) { + global $logger; $totals = ['errors' => 0, 'warnings' => 0, 'suggestions' => 0]; - $unscannables_items = []; - $content = []; + $unscannables_items = array(); + $content = array(); // combine the data from each job's results $sql = "SELECT * FROM job_queue WHERE job_group = '{$job_group}'"; @@ -182,12 +183,19 @@ protected static function combineJobResults($job_group) $totals['warnings'] += $results['total_results']['warnings']; $totals['suggestions'] += $results['total_results']['suggestions']; + // if the scan results array is empty for some reason, + // make sure it's an empty array and continue. + if (empty($results['scan_results'])) { + $content = array(); + } + // if unscannables are found, collect them if (!empty($results['scan_results']['unscannable'])) { $unscannables_items = array_merge($unscannables_items, $results['scan_results']['unscannable']); unset($results['scan_results']['unscannable']); } + // merge the scan results $content = array_merge($content, $results['scan_results']); } diff --git a/lib/quail/quail/common/accessibility_tests.php b/lib/quail/quail/common/accessibility_tests.php index 9b8cfb3bf..02f6acbbb 100755 --- a/lib/quail/quail/common/accessibility_tests.php +++ b/lib/quail/quail/common/accessibility_tests.php @@ -5724,12 +5724,14 @@ function check() foreach ($table->childNodes as $child) { if ($this->propertyIsEqual($child, 'tagName', 'tbody') || $this->propertyIsEqual($child, 'tagName', 'thead')) { foreach ($child->childNodes as $tr) { - foreach ($tr->childNodes as $th) { - if ($this->propertyIsEqual($th, 'tagName', 'th')) { - break 3; - } else { - $this->addReport($table); - break 3; + if (!is_null($tr->childNodes)) { + foreach ($tr->childNodes as $th) { + if ($this->propertyIsEqual($th, 'tagName', 'th')) { + break 3; + } else { + $this->addReport($table); + break 3; + } } } } From 9161e4c45a411c73985c369f9b4cf2aa8e2574b5 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 15 Feb 2018 16:38:20 -0500 Subject: [PATCH 6/7] Oops, was changing the wrong variable to an empty array. Fixes #328 --- lib/UdoitJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/UdoitJob.php b/lib/UdoitJob.php index 3736a94be..8fcfb531c 100644 --- a/lib/UdoitJob.php +++ b/lib/UdoitJob.php @@ -186,7 +186,7 @@ protected static function combineJobResults($job_group) // if the scan results array is empty for some reason, // make sure it's an empty array and continue. if (empty($results['scan_results'])) { - $content = array(); + $results['scan_results'] = array(); } // if unscannables are found, collect them From e345c89f6ad22ea869e328184863f801a2d13b04 Mon Sep 17 00:00:00 2001 From: Jacob Bates Date: Thu, 15 Feb 2018 17:06:36 -0500 Subject: [PATCH 7/7] Added status messages to migration scripts to help with debugging in the future --- migrations/000_db_create_tables.php | 2 ++ migrations/001_move_reports_to_db.php | 13 ++++++++----- migrations/002_add_background_queue.php | 2 ++ migrations/003_add_refresh_token_to_users.php | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/migrations/000_db_create_tables.php b/migrations/000_db_create_tables.php index aac88b458..e7e8ac732 100644 --- a/migrations/000_db_create_tables.php +++ b/migrations/000_db_create_tables.php @@ -30,6 +30,7 @@ if ('pgsql' === $db_type) { // POSTGRESQL + echo("Setting up tables in PostgreSQL\r\n"); $tables = [ ' CREATE TABLE IF NOT EXISTS reports ( @@ -55,6 +56,7 @@ if ('mysql' === $db_type) { // MYSQL + echo("Setting up tables in MySQL\r\n"); $tables = [ ' CREATE TABLE IF NOT EXISTS `reports` ( diff --git a/migrations/001_move_reports_to_db.php b/migrations/001_move_reports_to_db.php index 85d61f318..89bc68672 100644 --- a/migrations/001_move_reports_to_db.php +++ b/migrations/001_move_reports_to_db.php @@ -44,7 +44,7 @@ // if 'file_path' col is missing, there's nothing to do if (!$check_for_column($db_reports_table, 'file_path')) { if (!getenv('UNITTEST')) { - echo("It looks like this script doesnt need to be run"); + echo("No need to migrate old reports, continuing...\r\n"); } return; @@ -53,6 +53,7 @@ // add the column if it's missing if (!$check_for_column($db_reports_table, $col_to_add)) { // Quick hack to add report column since we dont have migrations yet + echo("Adding report_json column.\r\n"); $column_type = $db_type == 'mysql' ? 'MEDIUMTEXT' : 'TEXT'; UdoitDB::query("ALTER TABLE {$db_reports_table} ADD {$col_to_add} {$column_type}"); } @@ -60,12 +61,14 @@ // exit with warning if the column is still missing if (!check_for_column($dbh, $db_reports_table, $col_to_add)) { if (!getenv('UNITTEST')) { - echo("The migration script failed to create a ${col_to_add} column"); + echo("The migration script failed to create a ${col_to_add} column\r\n"); } return; } +echo("Migrating old reports from disk to database.\r\n"); + // Grab all rows from the reports table if ($rows = UdoidDB::query('SELECT * FROM reports')) { $rows = $rows->fetchAll(); @@ -82,7 +85,7 @@ $file = __DIR__.'/'.$row['file_path']; if (!file_exists($file)) { - echo("Json file not found {$file} for report id: {$row['id']}\n"); + echo("Json file not found {$file} for report id: {$row['id']}\r\n"); continue; } @@ -98,7 +101,7 @@ if (!$res) { print_r($sth->errorInfo()); - echo("Failed inserting report for {$row['id']}\n"); + echo("Failed inserting report for {$row['id']}\r\n"); continue; } @@ -106,4 +109,4 @@ } UdoitDB::query("ALTER TABLE {$db_reports_table} DROP COLUMN file_path"); -echo("Moved {$count_moved} reports from disk to the database. Feel free to delete the reports directory\n"); +echo("Moved {$count_moved} reports from disk to the database. Feel free to delete the reports directory\r\n"); diff --git a/migrations/002_add_background_queue.php b/migrations/002_add_background_queue.php index 866cc8ab2..93a09b542 100644 --- a/migrations/002_add_background_queue.php +++ b/migrations/002_add_background_queue.php @@ -24,6 +24,7 @@ if ('pgsql' === $db_type) { // POSTGRESQL + echo("Creating job_queue in PostgreSQL\r\n"); $queries = [ ' CREATE TABLE IF NOT EXISTS job_queue ( @@ -44,6 +45,7 @@ if ('mysql' === $db_type) { // MYSQL + echo("Creating job_queue in MySQL\r\n"); $queries = [ ' CREATE TABLE IF NOT EXISTS `job_queue` ( diff --git a/migrations/003_add_refresh_token_to_users.php b/migrations/003_add_refresh_token_to_users.php index c8edda70e..0c2b4e098 100644 --- a/migrations/003_add_refresh_token_to_users.php +++ b/migrations/003_add_refresh_token_to_users.php @@ -41,6 +41,7 @@ if ('pgsql' === $db_type) { // POSTGRESQL + echo("Adding refresh_token and canvas_url fields in PostgreSQL\r\n"); $queries = [ [ 'isRequired' => !$check_for_column('users', 'refresh_token'), @@ -55,6 +56,7 @@ if ('mysql' === $db_type) { // MYSQL + echo("Adding refresh_token and canvas_url fields in MySQL\r\n"); $queries = [ [ 'isRequired' => !$check_for_column('users', 'refresh_token'),