insert_record() function changes...

insert_record() function changes...

Eloy Lafuente (stronk7) -
Колькасьць адказаў: 1
Выява Core developers Выява Documentation writers Выява Moodle HQ Выява Peer reviewers Выява Plugin developers Выява Testers
Hi moodlers,

currently the insert_record() function, part of lib/datalib.php is defined as:
function insert_record($table, $dataobject, $returnid=true, $primarykey='id')
and I would want to discuss a bit about the 4th parameter in such definition, i.e. the $primarykey one.

It's primary goal is to allow Moodle DB tables to have primary key fields whose name was different from the standard "id" auto-numbered field (point 1).

After some discussions in this looong bug, it seems that, ASAP, we should delete such 4th parameter completely, to 100% enforce all Moodle tables to have such standard "id" field. Moodle's style, you know!

Currently under Moodle official code there aren't any line using that parameter so, form that perspective, we could delete that parameter now.

But, perhaps, this would make some contrib modules to stop working suddenly and we don't want this to happen, isn't it? падморгваньне

So, this discussion has, at least, two objectives:

1.- To inform all developers about the need to check their code, ensuring that all their DB tables have the "id" PK, auto-numbered field and that they aren't using the 4th field in their insert_record() calls.

2.- To discuss how we could give to developers some time to adapt their code without breaking it now. About this, I think we could start sending some "deprecated" info to the browser with "debug" enabled, plus some "error_log" messages to general log files. Then, after some weeks/months/releases, we could delete such 4th parameter safely forever.

How does this sound for you?

Ciao усьмешка
Сярэдняе рэйтынгаў:Useful (2)
У адказ на Eloy Lafuente (stronk7)

Re: insert_record() function changes...

Eloy Lafuente (stronk7) -
Выява Core developers Выява Documentation writers Выява Moodle HQ Выява Peer reviewers Выява Plugin developers Выява Testers
Hey,

as this discussion was getting pretty interesting I've moved all their posts to the other active discussion about the same issue:

http://moodle.org/mod/forum/discuss.php?d=38183

Please, continue there...considering this closed. TIA!

Ciao усьмешка