History | Log In     View a printable version of the current page.  
We are currently focused especially on Moodle 2.0, Moodle 1.9.x bugs and Moodle 1.9.x testing.    Confused? Lost? Please read this introduction to the Tracker.
Issue Details (XML | Word | Printable)

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

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: 26/Jun/08 01:39 AM
Component/s: General
Affects Version/s: 1.9, 2.0
Fix Version/s: 2.0

Issue Links:
Relates
 

Participants: Dongsheng Cai, Eloy Lafuente (stronk7), Mitsuhiro Yoshida, Pierre Pichet and Robert Allerstorfer
Security Level: None


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Dongsheng Cai - 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) - 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 - 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) - 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 - 23/Apr/08 09:54 AM
Thanks you advices, fixed

Robert Allerstorfer - 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 - 21/May/08 04:10 PM
763 left

Dongsheng Cai - 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 - 23/May/08 04:20 PM
620 left

Pierre Pichet - 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 - 24/May/08 10:42 PM
Hi, Pierre, feel free to do it, TIA :-)

Pierre Pichet - 24/May/08 11:28 PM
OK :-)

Pierre Pichet - 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 - 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 - 11/Jun/08 07:25 PM
Thanks I located them using "->error"

Dongsheng Cai - 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 - 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 - 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 - 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 - 16/Jun/08 12:05 AM
Thanks, Mitsuhiro, there may be many other mistakes, this issue reopened

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

Pierre Pichet - 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 - 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 - 25/Jun/08 07:28 PM
Thanks, Robert, I will fix them tomorrow :-)

Dongsheng Cai - 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 - 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.