Skip to content
Snippets Groups Projects

Add nice error message with links to skip sql functions update

Merged Marc Egger requested to merge marcUpdateSQLFunctionsNiceError into master
4 files
+ 37
8
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -165,10 +165,16 @@ class DatabaseUpdate {
* @throws UserFormException
*/
private function updateSqlFunctions($oldFunctionsHash) {
if ('no' === $oldFunctionsHash) {
if (ACTION_FUNCTION_UPDATE_NEVER === $oldFunctionsHash) {
return null;
}
if ($_GET[ACTION_FUNCTION_UPDATE] === ACTION_FUNCTION_UPDATE_NEXT_UPDATE) {
return ACTION_FUNCTION_UPDATE_NOT_PERFORMED;
} elseif ($_GET[ACTION_FUNCTION_UPDATE] === ACTION_FUNCTION_UPDATE_NEVER) {
return ACTION_FUNCTION_UPDATE_NEVER;
}
$functionsSql = file_get_contents(__DIR__ . '/../../sql/functions.sql');
$functionsHash = hash('md5', $functionsSql);
@@ -193,11 +199,17 @@ class DatabaseUpdate {
return $functionsHash;
} else {
$errorMsg[ERROR_MESSAGE_TO_USER] = 'Error while updating qfq.';
$errorMsg[ERROR_MESSAGE_TO_DEVELOPER] = "Error while updating qfq: " .
"Could not properly execute the file 'functions.sql' on the QFQ MYSQL database. " .
"Please do so manually or set the parameter 'functionsHash' in the table comments of the table" .
" 'Form' to 'no' i.e. 'Version=x.y.z&functionHash=no' to disable updating of the qfq mysql functions." .
" You may also try giving the mysql user the 'SUPER' privilege temporarily.";
$errorMsg[ERROR_MESSAGE_TO_DEVELOPER] =
"Failed to play functions.sql, probably not enough permissions for the qfq mysql user. " .
"Possible solutions: <ul>" .
'<li>Grant Super privilages to qfq mysql user temporarily.</li>' .
'<li>Play the following file manually on the database: ' .
'<a href="http://webwork16.math.uzh.ch/megger/qfq/typo3conf/ext/qfq/Source/sql/functions.sql">typo3conf/ext/qfq/Source/sql/functions.sql</a></li>' .
'<li><a href="?' . http_build_query(array_merge($_GET, array(ACTION_FUNCTION_UPDATE=>ACTION_FUNCTION_UPDATE_NEXT_UPDATE))) . '">Click here</a> to skip the sql functions update until next qfq release update</li>' .
'<li><a href="?' . http_build_query(array_merge($_GET, array(ACTION_FUNCTION_UPDATE=>ACTION_FUNCTION_UPDATE_NEVER))) . '">Click here</a> to skip the sql functions update forever</li>' .
'</ul>' .
"To enable the sql functions update again you can delete the parameter 'functionsHash' in the table comments of the table 'Form'.";
$errorMsg[ERROR_MESSAGE_TO_DEVELOPER_SANITIZE] = false;
throw new DbException(json_encode($errorMsg), ERROR_PLAY_SQL_FILE);
}
}
Loading