Permalink
Browse files

Merge branch 'MDL-39618-24' of git://github.com/danpoltawski/moodle i…

…nto MOODLE_24_STABLE
  • Loading branch information...
2 parents 98f4a31 + 8c5ca65 commit ada23f968ae4508d5515476d47029933faf52ec2 @marinaglancy marinaglancy committed Dec 9, 2013
Showing with 20 additions and 1 deletion.
  1. +2 −0 install/stringnames.txt
  2. +4 −0 lang/en/error.php
  3. +14 −1 lib/installlib.php
View
@@ -1,5 +1,6 @@
admindirname,install
availablelangs,install
+cannotcreatedboninstall,error
cannotcreatelangdir,error
cannotcreatetempdir,error
cannotdownloadcomponents,error
@@ -28,6 +29,7 @@ databasetypehead,install
dataroot,install
datarootpermission,install
dbprefix,install
+dmlexceptiononinstall,error
dirroot,install
downloadedfilecheckfailed,error
environmenthead,install
View
@@ -46,6 +46,9 @@
$string['cannotcallusgetselecteduser'] = 'You cannot call user_selector::get_selected_user if multi select is true.';
$string['cannotcreatebackupdir'] = 'Could not create backupdata folder. The site administrator needs to fix the file permissions';
$string['cannotcreatecategory'] = 'The category was not inserted';
+$string['cannotcreatedboninstall'] = '<p>Cannot create the database.</p>
+<p>The specified database does not exist and the given user does not have permission to create the database.</p>
+<p>The site administrator should verify database configuration.</p>';
$string['cannotcreategroup'] = 'Error creating group';
$string['cannotcreatelangbase'] = 'Error: Could not create base lang directory';
$string['cannotcreatelangdir'] = 'Cannot create lang directory';
@@ -199,6 +202,7 @@
$string['ddlxmlfileerror'] = 'XML database file errors found';
$string['destinationcmnotexit'] = 'The destination course module does not exist';
$string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.';
+$string['dmlexceptiononinstall'] = '<p>A database error has occurred [{$a->errorcode}].<br />{$a->debuginfo}</p>';
$string['dmlreadexception'] = 'Error reading from database';
$string['dmltransactionexception'] = 'Database transaction error';
$string['dmlwriteexception'] = 'Error writing to database';
View
@@ -192,7 +192,20 @@ function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $pre
}
return '';
} catch (dml_exception $ex) {
- return get_string($ex->errorcode, $ex->module, $ex->a).'<br />'.$ex->debuginfo;
+ $stringmanager = get_string_manager();
+ $errorstring = $ex->errorcode.'oninstall';
+ $legacystring = $ex->errorcode;
+ if ($stringmanager->string_exists($errorstring, $ex->module)) {
+ // By using a different string id from the error code we are separating exception handling and output.
+ return $stringmanager->get_string($errorstring, $ex->module, $ex->a).'<br />'.$ex->debuginfo;
+ } else if ($stringmanager->string_exists($legacystring, $ex->module)) {
+ // There are some DML exceptions that may be thrown here as well as during normal operation.
+ // If we have a translated message already we still want to serve it here.
+ // However it is not the preferred way.
+ return $stringmanager->get_string($legacystring, $ex->module, $ex->a).'<br />'.$ex->debuginfo;
+ }
+ // No specific translation. Deliver a generic error message.
+ return $stringmanager->get_string('dmlexceptiononinstall', 'error', $ex);
}
}

0 comments on commit ada23f9

Please sign in to comment.