Moodle

Empty old_id during an assignment recover throws an error

Details

  • Database:
    PostgreSQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Error at three places:
=======================================================
ERROR: invalid input syntax for integer: ""
DELETE FROM mdl_backup_ids
WHERE backup_code = 1202567977 AND
table_name = 'assignment' AND
old_id = ''
...
line 451 of backup/lib.php: call to backup_delid()
...

=======================================================
ERROR: invalid input syntax for integer: ""
DELETE FROM mdl_backup_ids
WHERE backup_code = 1202567977 AND
table_name = 'quiz' AND
old_id = ''
...
line 451 of backup/lib.php: call to backup_delid()
...
=======================================================
ERROR: invalid input syntax for integer: ""
SELECT * FROM mdl_backup_ids WHERE backup_code = '1202567977' AND table_name = 'assignment' AND old_id = '

...
line 32 of mod/assignment/restorelib.php: call to backup_getid()
...

=======================================================

I do not know if this is problem of dmlib, backup/recovery or assignment module. I will try to look at assignment to realize if empty old_id is allowed during recovery process.

Activity

Hide
David Mudrak added a comment -

After some research, this seems to be a result of combination of several incidents. Somehow (I am trying to find out how) the ZIP course backup contains "empty" module instances like:
<INSTANCES>
<INSTANCE>
<ID></ID>
<NAME></NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>false</USERINFO>
</INSTANCE>
</INSTANCES>

<MOD>
<ID></ID>
<MODTYPE>assignment</MODTYPE>
<NAME></NAME>
<DESCRIPTION></DESCRIPTION>
<FORMAT></FORMAT>
<RESUBMIT></RESUBMIT>
<PREVENTLATE></PREVENTLATE>
<EMAILTEACHERS></EMAILTEACHERS>
<VAR1></VAR1>
<VAR2></VAR2>
<VAR3></VAR3>
<VAR4></VAR4>
<VAR5></VAR5>
<ASSIGNMENTTYPE></ASSIGNMENTTYPE>
<MAXBYTES></MAXBYTES>
<TIMEDUE></TIMEDUE>
<TIMEAVAILABLE></TIMEAVAILABLE>
<GRADE></GRADE>
<TIMEMODIFIED></TIMEMODIFIED>
</MOD>

This XML record is then processed by backup_delid() and other backup functions: <ID></ID> => $old_id="" => error on PostgreSQL 8.

So, the major problem here is how the ZIP backup may contain an empty mod instance record

Show
David Mudrak added a comment - After some research, this seems to be a result of combination of several incidents. Somehow (I am trying to find out how) the ZIP course backup contains "empty" module instances like: <INSTANCES> <INSTANCE> <ID></ID> <NAME></NAME> <INCLUDED>true</INCLUDED> <USERINFO>false</USERINFO> </INSTANCE> </INSTANCES> <MOD> <ID></ID> <MODTYPE>assignment</MODTYPE> <NAME></NAME> <DESCRIPTION></DESCRIPTION> <FORMAT></FORMAT> <RESUBMIT></RESUBMIT> <PREVENTLATE></PREVENTLATE> <EMAILTEACHERS></EMAILTEACHERS> <VAR1></VAR1> <VAR2></VAR2> <VAR3></VAR3> <VAR4></VAR4> <VAR5></VAR5> <ASSIGNMENTTYPE></ASSIGNMENTTYPE> <MAXBYTES></MAXBYTES> <TIMEDUE></TIMEDUE> <TIMEAVAILABLE></TIMEAVAILABLE> <GRADE></GRADE> <TIMEMODIFIED></TIMEMODIFIED> </MOD> This XML record is then processed by backup_delid() and other backup functions: <ID></ID> => $old_id="" => error on PostgreSQL 8. So, the major problem here is how the ZIP backup may contain an empty mod instance record
Hide
David Mudrak added a comment -

OK, I have got it. The problem with empty record in moodle.xml occurs in case when:

  • the module record exists in the table COURSE_MODULES
  • but the instance of the module does not exist

Apparently, backup process does not check that the instance really exists. This might be considered as a bug.

I propose to close this as "not a bug"

Show
David Mudrak added a comment - OK, I have got it. The problem with empty record in moodle.xml occurs in case when:
  • the module record exists in the table COURSE_MODULES
  • but the instance of the module does not exist
Apparently, backup process does not check that the instance really exists. This might be considered as a bug. I propose to close this as "not a bug"
Hide
Petr Škoda (skodak) added a comment -

backup fixed, thanks for the report

Show
Petr Škoda (skodak) added a comment - backup fixed, thanks for the report
Hide
Eloy Lafuente (stronk7) added a comment -

Looks perfect. Closing...

Show
Eloy Lafuente (stronk7) added a comment - Looks perfect. Closing...

People

Dates

  • Created:
    Updated:
    Resolved: