Invalid repository id

Invalid repository id

by John G. -
Number of replies: 5

Weird error.

I created a book on a course and i got a big error message. "Error code: invalidrepositoryid" cant access that course anymore, always get that error.

However, I tried to create a "book" in another course and all went smooth. It works and i can't reproduce this error again...

 

I need to recover the course without losing its contents so deleting it is out of the question... I've been on the database looking around and i can't figure out which repository id is bugging.

I haven't touched repositories for a long time... and a book isn't a repository... The only custom repository i have is working properly.

 

here's the error messagem:

Debug info: 
Error code: invalidrepositoryid
Stack trace:
  • line 590 of /repository/lib.php: repository_exception thrown
  • line 65 of /lib/filestorage/stored_file.php: call to repository::get_repository_by_id()
  • line 152 of /lib/filestorage/file_storage.php: call to stored_file->__construct()
  • line 581 of /lib/filestorage/file_storage.php: call to file_storage->get_file_instance()
  • line 256 of /mod/resource/lib.php: call to file_storage->get_area_files()
  • line 942 of /course/lib.php: call to resource_get_coursemodule_info()
  • line 1461 of /lib/modinfolib.php: call to get_array_of_activities()
  • line 249 of /lib/modinfolib.php: call to rebuild_course_cache()
  • line 1393 of /lib/modinfolib.php: call to course_modinfo->__construct()
  • line 1416 of /lib/datalib.php: call to get_fast_modinfo()
  • line 304 of /mod/assign/lib.php: call to get_all_instances_in_courses()
  • line 35 of /blocks/course_overview/locallib.php: call to assign_print_overview()
  • line 68 of /blocks/course_overview/block_course_overview.php: call to block_course_overview_get_overviews()
  • line 292 of /blocks/moodleblock.class.php: call to block_course_overview->get_content()
  • line 238 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 951 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1003 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 315 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 1232 of /lib/outputrenderers.php: call to block_manager->get_content_for_region()
  • line 155 of /my/index.php: call to core_renderer->blocks_for_region()

Thanks for the help.

Average of ratings: Useful (1)
In reply to John G.

Re: Invalid repository id

by John G. -

Ok so i fixed the problem with the help of "dobedobedoh" from IRC channel #moodle at freenode.

 

first we found which ID was the faulty repository. I went to file repository/lib.php and added a var_dump($repositoryid); before line 590.

This tells me which ID was faulty and it happened to be ID 9.

I logged in on phpmyadmin and checked the repository table. There was no repository id 9.

next we tried to find out which file was causing the error.

Headed to lib/filestorage/stored_file.php and in line 65 added 

if ($file_record->repositoryid == 9) { print_object($file_record); }

this would let me know exactly which file was causing the error and it happned to be a file I uploaded using the dropbox repository. I wasn't using this repository anymore but apparently the database still had the reference to that file.

again, jumped in the database and checked the files_reference table and there it was. I deleted that record and everything is fine gain.

 

hope this helps to whoever has a similar problem. And once again thanks to dobedobedoh.

 

 

Average of ratings: Useful (2)
In reply to John G.

Re: Invalid repository id

by Johnny Zghaib -
yes apparently that is the way to go, it worked like a charm. but still i did not get to know  dobedobedoh, where can i find this guy?
In reply to John G.

Re: Invalid repository id

by Andrew Normore -

VERY helpful, thanks for sharing your information.

Make sure to turn on your Debugging mode first! My VarDumps were burried elsewhere and I couldn't see them smile


We ended up with an OLD repository that had been deleted from the system, but some how was still being referenced. I just did a:


DELETE FROM `mdl_files_reference` WHERE repositoryid = 1


and boom, backups are working again. 

Average of ratings: Useful (1)
In reply to John G.

Re: Invalid repository id

by Randy Thornton -
Picture of Documentation writers

Also, wanted to say, very helpful. I found an abandoned repository with id=9 and a lone file still referencing it.

I used the same trick that Andrew posted and removed that from mdl_files_reference, and problem fixed.