Issue Details (XML | Word | Printable)

Key: MDL-15094
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Petr Skoda
Reporter: Nicolas Connault
Votes: 0
Watchers: 1
Operations

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

M2-M3-M4 Upgrade all code using DML

Created: 03/Jun/08 06:37 AM   Updated: 24/Sep/08 05:06 AM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 2.0
Fix Version/s: 2.0

File Attachments: 1. File search_dml (0.4 kB)

Issue Links:
Blockers
 
Cloners
 

Participants: Nicolas Connault, Petr Skoda and Pierre Pichet
Security Level: None
Resolved date: 24/Sep/08
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE

Sub-Tasks  All   Open   
 Sub-Task Progress: 

 Description  « Hide
Since the new DML 2.0 API is now in place, all code using the old dmllib needs to be upgraded. In essence, this means the following changes:

1. Wherever old functions are used (get_record*, get_field*, set_field, insert_record, update_record), the global $DB must be used as the object on which these functions are called (e.g. get_record_select becomes $DB->get_record_select).

2. All the functions that used to accept a list of string params in the form "param1, value1, param2, value2" now need to be given an array of key=>value pairs as a replacement for these params. Other params remain as before. Check the new API for any exceptions.

3. rs_fetch_next_record($rs) is deprecated, in favour of the simple foreach($rs as $var). Calls to rs_close() must be replaced by $rs->close();

As an example to #3, if you have the original code:

     while($result = rs_fetch_next_record($rs)) {
         ...
     }
     rs_close();

you would replace it with

     foreach ($rs as $result) {
          ....
     }
     $rs->close();

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Skoda added a comment - 03/Jun/08 06:58 AM
At the same time code should be converted to not rely on magic quotes:

1/ form->get_data(false) returns form data without magic quotes

2/ data_submitted(false) return form data without magic quotes

3/ add stripslashes() after optional|required_param() - separate line preferable

4/ keep addslashes_js()!! - javascript quoting, XSS prevention; some existing addslashes() are incorrect


Pierre Pichet added a comment - 03/Jun/08 07:12 AM
Can you give us the time scale (in the northern hemisphere summer holidays are coming) to do the job.

This will also put a major "chinese wall" between 2.0 and older versions so that merging down to even 1.9 will be a very "cautious if not impossible " procedure. But I suppose that have been discussed elsewhere.


Pierre Pichet added a comment - 03/Jun/08 07:22 AM
Sorry, I probably misreaded
." All the functions that used to accept a list of string params in the form "param1, value1, param2, value2" now need to be given an array of key=>value pairs as a replacement for these params. Other params remain as before. Check the new API for any exceptions. "

So list of string params in the form "question_id1, question_id2,question_id3 "remains as they are?

And the only changes are adding $DB-> before functions as $DB->get_record_select ()?

If this is so, the height of the "chinese wall" decreased...


Nicolas Connault added a comment - 03/Jun/08 09:49 PM
Please read http://docs.moodle.org/en/Development:dmllib_2.0_migration_docs for more complete documentation.

Pierre Pichet added a comment - 04/Jun/08 02:23 AM
Nicolas,
Thanks for the reference.
I am willing to do the work on the part of the question code that I know well, so to be able to test everything correctly.
However I cannot do this before mid-august, is it to late ?

Nicolas Connault added a comment - 04/Jun/08 03:35 AM
Thanks Pierre, but it will be too late I think, maybe Petr can correct me on this...

Nicolas Connault added a comment - 06/Jun/08 03:50 PM
Just attached a script which recursively searches the folder in which it is run, looking for patterns of code that needs upgrading to the new DML syntax. It uses grep to output all the matching lines to standard output, and produces a summary text file (dml_search_summary) listing the files with matches, and showing the count of matches within each file.

Petr Skoda added a comment - 06/Jun/08 04:42 PM
oh, this conversion must be finished next week

Petr Skoda added a comment - 09/Jun/08 03:52 AM
I am planning to finish the dml conversion on Monday (9th) and on Tuesday start the magic quotes elimination
Please hurry with the commits, minor breakages are not a problem

Petr Skoda added a comment - 09/Jun/08 08:30 PM
all except global search finished - yay!

Petr Skoda added a comment - 15/Jun/08 05:36 PM
reopening searchlib missing

Petr Skoda added a comment - 15/Jun/08 06:12 PM
done

Petr Skoda added a comment - 24/Sep/08 05:06 AM
seems to be working fine for some time, reclosing