Can not find data record in database table context

Can not find data record in database table context

by Jason Stiner -
Number of replies: 5

Moodle Version : Moodle 3.5.3+ (Build: 20181201)

PHP Version : 7.0.7-50.41.1.x86_64

Error Message : Can not find data record in database table context
System Specs : Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
                            PL/SQL Release 12.1.0.2.0 - Production
                        "CORE   12.1.0.2.0          Production"
                        TNS for Linux: Version 12.1.0.2.0 - Production
                   NLSRTL Version 12.1.0.2.0 – Production
Current Theme : Boost
Change Log : none that we know of, but instructors are pepping for a new term
Attempted Fixes : https://moodle.org/mod/forum/discuss.php?d=199860
Debugging log : nothing relevant to courses.


This seems to only be effecting 1 student.  this is not the students first term. any time they try to log in or i attempt to pull the student up the error Can not find data record in database table context appears. 

attempted all the fixes from the link above. 

went through server error logs and made and fixes that could be corrected.  main issue was an old mediasite plug in that needed deleted. 


any other thoughts?




Average of ratings: -
In reply to Jason Stiner

Re: Can not find data record in database table context

by Jason Stiner -
i altered a query from the link [https://moodle.org/mod/forum/discuss.php?d=199860] and was able to get a lot of results.
SELECT * FROM m_context ctx
LEFT JOIN m_context PARENT ON ctx.path LIKE ('%/' || parent.id || '/' || ctx.id)
WHERE parent.id IS NULL
OR ctx.path <> (parent.path || '/' || ctx.id)
which should correspond to the categories that the problem courses are in. Or perhaps the categories got deleted somehow, but the courses are still there.

i'm just not sure how to safely proceed.
In reply to Jason Stiner

Re: Can not find data record in database table context

by Jason Stiner -

we got debugging turned on and this is the error that came up

from that we checked the user_enrollments, enrollments, courses, and grade/grade_items tables. 

(after backing up the table)

removed the grade information for 19301 as that is the only table information for that courseID existed. 

we are still getting the same error as listed below. 

Debug info: SELECT id,category FROM {course} WHERE id = :id

[array (
'id' => '19301',
)]
Error code: invalidrecord
×Stack trace:
  • line 1546 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 6556 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 40 of /badges/renderer.php: call to context_course::instance()
  • line 58 of /badges/lib.php: call to core_badges_renderer->print_badges_list()
  • line 66 of /user/classes/output/myprofile/manager.php: call to core_badges_myprofile_navigation()
  • line 218 of /user/profile.php: call to core_user\output\myprofile\manager::build_tree()

In reply to Jason Stiner

Re: Can not find data record in database table context

by Jason Stiner -

we got debugging turned on and this is the error that came up

from that we checked the user_enrollments, enrollments, courses, and grade/grade_items tables. 

(after backing up the table)

removed the grade information for 19301 as that is the only table information for that courseID existed. 

we are still getting the same error as listed below. 

Debug info: SELECT id,category FROM {course} WHERE id = :id

[array (
'id' => '19301',
)]
Error code: invalidrecord
×Stack trace:
  • line 1546 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 6556 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 40 of /badges/renderer.php: call to context_course::instance()
  • line 58 of /badges/lib.php: call to core_badges_renderer->print_badges_list()
  • line 66 of /user/classes/output/myprofile/manager.php: call to core_badges_myprofile_navigation()
  • line 218 of /user/profile.php: call to core_user\output\myprofile\manager::build_tree()

In reply to Jason Stiner

Re: Can not find data record in database table context

by Jason Stiner -

with the below insert i was able to restore the users account. 
while keeping the "fake" course of Archive hidden from the students view.

INSERT INTO mdl_course c
( c.id, c.category, c.sortorder, c.fullname, c.shortname, c.idnumber, c.summary, c.summaryformat, c.format, c.showgrades, c.newsitems, c.startdate, 
c.marker, c.maxbytes, c.legacyfiles, c.showreports, c.visible, c.visibleold, c.groupmode, c.groupmodeforce, c.defaultgroupingid, c.lang, 
c.theme, c.timecreated, c.timemodified, c.requested, c.enablecompletion, c.completionnotify, c.calendartype, c.cacherev, c.enddate)
VALUES
(19301, 601,460015, 'Archive', 'Archv', 1, NULL, 0, 'weeks', 0, 1, 0, 0,0, 0 , 0 , 0 , 0 , 0, 0 , 0 ,'en_us', ' ',0,0,0,0,0,' ',1566242818, 0 )


In reply to Jason Stiner

Re: Can not find data record in database table context

by Carlos Zevallos -
Información de depuración: SELECT * FROM {context} WHERE contextlevel =?
[matriz (
0 => 10,
)]
Código de error: registro inválido
Seguimiento de pila:
línea 1562 de /lib/dml/moodle_database.php: arrojado dml_missing_record_exception
línea 1538 de /lib/dml/moodle_database.php: llame a moodle_database-> get_record_select ()
línea 6167 de /lib/accesslib.php: llamada a moodle_database-> get_record ()
línea 747 de /lib/setup.php: llamada al contexto_sistema :: instancia ()
línea 35 de /config.php: call to require_once ()
línea 30 de /index.php: call to require_once ()
Alguien puede ayudarme con esto por favor