Issue Details (XML | Word | Printable)

Key: MDL-14129
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dongsheng Cai
Reporter: Dongsheng Cai
Votes: 0
Watchers: 5
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-14085

Remove all the other error() call(head only)

Created: 01/Apr/08 11:56 AM   Updated: 23/Mar/09 07:45 PM
Component/s: General
Affects Version/s: 1.9, 2.0
Fix Version/s: 2.0

Issue Links:
Dependency
 
Relates
 

Participants: Dongsheng Cai, Eloy Lafuente (stronk7), Mitsuhiro Yoshida, Pierre Pichet and Robert Allerstorfer
Security Level: None
Resolved date: 12/Dec/08
Affected Branches: MOODLE_19_STABLE, MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Dongsheng Cai added a comment - 04/Apr/08 11:40 AM
All the error() calls are changed to print_error() now, creating error strings may take a while, tooooo many strings need to be created.

Eloy Lafuente (stronk7) added a comment - 07/Apr/08 08:38 AM - edited
Wow,

I thought your were going to do this "gradually", adding new strings and changing some calls each day.

In fact, now that all them are "correct" print_error() calls it's more difficult to find them, when it was trivial to do before your commit. Also be prevented about those BIG commits because they use to make more difficult to merge things (sometimes, not now, I guess) and to revert and so on. Just a recommendation.

And yes, next step is about to creating error strings and replace them in current calls to print_error(), that's a huge task (I'd recommend to make that "gradually" )

Ciao


Dongsheng Cai added a comment - 07/Apr/08 11:28 AM
Oops, sorry, I didn't realize these problems before I commited changes, I will be careful about these changes from now on, thanks for your recommendation, Eloy.

Eloy Lafuente (stronk7) added a comment - 23/Apr/08 07:47 AM
Hi Dongsheng,

just saw you latest gradual changes about this issue and have found that here:

http://cvs.moodle.org/moodle/backup/backup.php?r1=1.48&r2=1.49

You've used the same error string "cannotusepage" in THREE places. If you look at this carefully you'll see that the second replacement is incorrect, only admins can use that page (whereas the rest are admins and teachers).

I'd suggesto you to fix this by:

1) Adding some different lang strings like:

cannotuseadmin
cannotuseadminadminorteacher
...

(i.e. all them will start by "cannotuse" followed by the list of roles allowed to use the page). Just a example proposal, feel free to improve it.

2) Apply then where necessary.

That way, always you find one error message, you can resuse those langs strings safely in future changes of this gradual task.

Ciao


Dongsheng Cai added a comment - 23/Apr/08 09:54 AM
Thanks you advices, fixed

Robert Allerstorfer added a comment - 14/May/08 02:21 PM
As it seems, the transition from error() to print_error() does now not only go to HEAD, but to MOODLE_19_STABLE as well. Thus, should error() no more be used when creating new error checks in the STABLE branch?

Why using the error string
cannotuseadminadminorteacher (cannotuse admin admin or teacher)
at http://cvs.moodle.org/moodle/backup/backup.php?r1=1.50&r2=1.48 ?


Dongsheng Cai added a comment - 21/May/08 04:10 PM
763 left

Dongsheng Cai added a comment - 21/May/08 04:14 PM
Hi, Robert, you'd better use print_error from now on, you can easily merge new error check to HEAD.

Dongsheng Cai added a comment - 23/May/08 04:20 PM
620 left

Pierre Pichet added a comment - 24/May/08 10:00 PM
Hi Dongsheng,
Thanks for your tedious but necessary work on print_error.
However you have done some changes on multianswer/questiontype (19 may)
/// MULTIANSWER /// (Embedded - cloze)
@@ -439,7 +439,7 @@
echo $feedbackimg;
break;
default:
  • print_error("Unable to recognize questiontype of question part #$positionkey.");
    + print_error('unknownquestiontype', 'question');
    break;
    }
    echo "</label>"; // MDL-7497
    @@ -672,7 +672,7 @@
    $answer = $exploded[1];
    // $sequence is an ordered array of the question ids.
    if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $state->question)) { - print_error("The cloze question $state->question is missing its options"); + print_error('missingoption', 'question', '', $state->question); }
    $sequence = explode(',', $sequence);
    // The id of the current question.
    @@ -799,7 +799,7 @@
    $wrapped->partiallycorrectfeedback = '';
    $wrapped->incorrectfeedback = '';
    } else { - print_error("Cannot identify qtype $answerregs[2]"); + print_error('unknownquestiontype', 'question', '', $answerregs[2]); return false; }
    The multianswer being the only one of its type in the actual question bank, identifying which subquestion have a problem needs specific infos.
    So I propose to create specific message in lang qtype_multianswer.php and refer to them in the print_erro call.
    If you agree, I will do the necessary work so that you can continue on the 620 left ...

Dongsheng Cai added a comment - 24/May/08 10:42 PM
Hi, Pierre, feel free to do it, TIA

Pierre Pichet added a comment - 24/May/08 11:28 PM
OK

Pierre Pichet added a comment - 11/Jun/08 05:02 PM
There are some hidden error calls in question code related to the return from questiontype save_question_options()
i.e. line 366 of question/type/questiontype.php
$result->error = "No data for field $field when saving " .
$this->name() . ' question id ' . $question->id;
and used line 318 as
if (!empty($result->error)) { print_error($result->error); }

they can be found by searching ->error in question files.
I will take care of them


Dongsheng Cai added a comment - 11/Jun/08 05:23 PM
In addition, some print_error like:
print_error( $this->error );

This command will help you find them:
grep "print_error([$ ]" --color -rn .


Pierre Pichet added a comment - 11/Jun/08 07:25 PM
Thanks I located them using "->error"

Dongsheng Cai added a comment - 15/Jun/08 08:26 PM
All done!! (Is this the longest change list in moodle?)

Please reopen it if you find more unfixed print_error calls or hidden ones, TIA.


Pierre Pichet added a comment - 15/Jun/08 10:27 PM
It is OK for direct print_error calls, however the main project is also to remove all hardcoded error messages and in question code the work on indirect error is not finished. so don't close.

Mitsuhiro Yoshida added a comment - 15/Jun/08 11:53 PM
Hi Dongsheng,

Thanks for your hardworking
I fixed some of your new strings as below.

[error.php]
-$string['csvloaderror'] = 'Error occur during loading vcs file!';
+$string['csvloaderror'] = 'Error occur during loading CSV file!';

[scorm.php]
-$string['cannotfindsco'] = 'Cannot found SCO';
+$string['cannotfindsco'] = 'Could not find SCO';

And we need to add one more string $string['secretalreadyused'] to error.php.
This string is used for login/forget_password.php.

Mits


Dongsheng Cai added a comment - 15/Jun/08 11:57 PM
Pierre,I changed the indirect error:
print_error($result->error);
to:
print_error('questionsaveerror', 'question', '', $result->error);

It is ugly, do you have any better idea?
I found more indirect error in other modules, I made a "TODO" mark in source code.


Dongsheng Cai added a comment - 16/Jun/08 12:05 AM
Thanks, Mitsuhiro, there may be many other mistakes, this issue reopened

Dongsheng Cai added a comment - 16/Jun/08 12:14 AM
I found $string['secretalreadyused'] in lang/en_utf8/moodle.php, I copied one to error.php

Pierre Pichet added a comment - 16/Jun/08 02:28 AM
The main idea is that result->error contains the correct string using the get_string('erroe..','question or qtype')
so that you use print_error($result->error);

Robert Allerstorfer added a comment - 25/Jun/08 07:25 PM
Hi Dongsheng,

there are still calls to error() in the HEAD versions of mod/data/lib.php and mod/data/preset.php


Dongsheng Cai added a comment - 25/Jun/08 07:28 PM
Thanks, Robert, I will fix them tomorrow

Dongsheng Cai added a comment - 26/Jun/08 12:33 AM
Robert, I replaced all error() calls in data mod. It seems some print_error calls are reverted when I focus on this issue, that why I didn't find them.
More work need to be done

Robert Allerstorfer added a comment - 26/Jun/08 01:39 AM
Thank you for your quick response, Dongsheng!

I just replaced "invildpreset" by the proper wording "invalidpreset" introduced by your last commit.


Dongsheng Cai added a comment - 12/Dec/08 02:56 PM
There are a few error() in filtering system, they will be fixed in MDL-14582.
Other error()s are removed from moodle HEAD, please report to here if you find more.
Thanks.