From: dongsheng Date: Wed, 14 May 2008 02:54:18 +0000 (+0000) Subject: "MDL-14442, some error checking added" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=64e6c53d57f884caf73c56d5ce74baa94977b622;p=moodle.git "MDL-14442, some error checking added" --- diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 3b5cd26764..26e55cbcb0 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -51,6 +51,7 @@ $string['cannotreadtmpfile'] = 'Error reading temporary file'; $string['cannotremovefrommeta'] = 'Could not remove the selected course from this meta course!'; $string['cannotrestore'] = 'An error has occurred and the restore could not be completed!'; $string['cannotsavefile'] = 'Cannot save the file \"$a\".'; +$string['cannotinsertrecord'] = 'Could not insert new record ID $a'; $string['cannotsavemd5file'] = 'Cannot save md5 file.'; $string['cannotsavezipfile'] = 'Cannot save ZIP file.'; $string['cannotsetupcategory'] = 'Serious Error! Could not set up a default course category!'; @@ -59,6 +60,7 @@ $string['cannotunzipfile'] = 'Cannot unzip file.'; $string['cannotupdatecategory'] = 'Could not update the category ($a)'; $string['cannotupdatecm'] = 'Could not update the course module with the correct section'; $string['cannotupdatelevel'] = 'Could not update the indent level on that course module'; +$string['cannotupdaterecord'] = 'Could not update record ID $a'; $string['cannotupdaterole'] = 'Cannot update role!'; $string['cannotupdatemod'] = 'Could not update the $a'; $string['cannotupdateuser'] = 'updating user failed'; diff --git a/mod/data/import.php b/mod/data/import.php index 8e24d1bcbd..c073a5cdc3 100755 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -116,7 +116,9 @@ $content = new object(); $content->recordid = $recordid; $content->fieldid = $field->id; - insert_record('data_content', $content); + if (! insert_record('data_content', $content)) { + print_error('cannotinsertrecord', '', '', $recordid); + } } // Fill data_content with the values imported from the CSV file: foreach ($record as $key => $value) { @@ -137,7 +139,9 @@ } $oldcontent = get_record('data_content', 'fieldid', $field->id, 'recordid', $recordid); $content->id = $oldcontent->id; - update_record('data_content', $content); + if (! update_record('data_content', $content)) { + print_error('cannotupdaterecord', '', '', $recordid); + } } $recordsadded++; print get_string('added', 'moodle', $recordsadded) . ". " . get_string('entry', 'data') . " (ID $recordid)
\n";