Issue Details (XML | Word | Printable)

Key: MDL-18497
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Blocker Blocker
Assignee: Eloy Lafuente (stronk7)
Reporter: Tim Hunt
Votes: 0
Watchers: 0
Operations

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

Cannot add a new field to a table with the XMLDB editor

Created: 10/Mar/09 10:06 AM   Updated: 25/Jul/09 12:04 AM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: David Balch, Eloy Lafuente (stronk7) and Tim Hunt
Security Level: None
Resolved date: 31/May/09
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
Try to add a new field called questiondecimalpoints int(4) signed not null default -1 with comment "The number of decimal digits to use when displaying question grades. -1 = use decimalpoints, otherwise a separate setting."

I get the error:

Fatal error: Call to a member function getHash() on a non-object in /home/tim/Workspace/moodle_head/admin/xmldb/actions/edit_field_save/edit_field_save.class.php on line 109


This is becuase XMLDB is trying to get the old hash of the field, so it can later see if anything has changed. However, the previous line $table->getField returns NULL, since this is a new field that was not present in the old structure.

Strangely, this code has not changed since it was added to core in August 2006: http://cvs.moodle.org/moodle/admin/xmldb/actions/edit_field_save/edit_field_save.class.php?hideattic=0&revision=1.1&view=markup


Similarly, the method table->getField, although it has moved several times, has not changed at all: http://cvs.moodle.org/moodle/lib/xmldb/classes/XMLDBTable.class.php?hideattic=0&revision=1.22&view=markup, and it has always returned null in this situation.


So, how the hell did it ever used to work. More to the point, why is it that every time I try to use XMLDB, it seems like I have to fix some bugs in it first?

/me goes to edit the XML by hand and swear and curse about the stupid, unnecessary, prev and next attributes.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 23/Mar/09 03:10 PM
Grrrrrrrrrrrrrrrrrrrrr!

Just hit this again.

Please fix.

Please, please, please!


Tim Hunt added a comment - 23/Mar/09 03:22 PM
Ah, the bug occurs if you add a new table, then immediately try to add a field.

If you add a new table, save the XML file, then reload the XML file, you can add a field.


Eloy Lafuente (stronk7) added a comment - 27/Apr/09 01:37 PM
From Tim, HQ chat:

"I think the problem is with multiple broswer tabs. For example, if you go and look at the definition to another field to see what type it is. That then causes an error when you save the one you are working on."

review the flow of that info... it shouldn't rely on session at all.


Eloy Lafuente (stronk7) made changes - 27/May/09 06:33 AM
Field Original Value New Value
Parent MDL-19303 [ 32107 ]
Issue Type Bug [ 1 ] Sub-task [ 5 ]
Eloy Lafuente (stronk7) added a comment - 31/May/09 06:59 AM
Uhm,

I've been trying to reproduce this in all ways possible:

  • Create table, then field, back without saving
  • Create table, then field, save (both without modifying the default "changeme" names and modifying them)
  • Create and then, while editing the new field, in other tab (same session), look another exiting field specs (edit it, both saving and without saving)
  • Force multiple "new field" executions to see if something is being reused incorrectly

And I haven't been able to get any error like the described above. So I'm going to close this as cannot reproduce. Please, if you find some sequence causing it... reopen and comment!

Slightly offtopic: Some days ago, I discovered that Moodle 2.0 sessions weren't being closed properly (due to one error in the destructor)... perhaps that could be causing some malfunction in session data, specially affecting the XMLDB editor when using more that one tab/window. Just a thought, not sure.

Ciao


Eloy Lafuente (stronk7) made changes - 31/May/09 06:59 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Cannot Reproduce [ 5 ]
Tim Hunt added a comment - 02/Jun/09 11:13 AM
OK. If I hit this again, I will reopen with full details. Thanks.

David Balch added a comment - 24/Jul/09 11:55 PM
I haven't debugged, but I can reliably reproduce this on Moodle 1.9.5+ (Build: 20090724)...
Trying to add a field to mod/assignment/db/assignment fails.

Name: requirestudentdeclaration
Comment: Force the student to check a box following a statement about the work, e.g. not having plagiarized.
Type: int
Length: 2
Not null: not null
Default: 0

However, I was able to add a different field to mod/assignment/db/assignment_submissions.


David Balch added a comment - 25/Jul/09 12:04 AM
Ah, hadn't seen the comments - I tried adding the field without opening a tab to refer to another field, and it worked.