Aadar Theme - Can not find data record in database table context.

Aadar Theme - Can not find data record in database table context.

by Finton Paul -
Number of replies: 11

Hi

I am using Moodle 2.4.3 and experiencing an inability to configure the dashboard icons. Each time I click on the appropriate area (a circular icon at the bottom of each rectangular block) the following message is visible.

The structure of the context table in control panel...phpadmin is as follows:

 

Any help would be much appreciated.

NB: I have successfully installed this theme on another site with moodle 2.4 installed.

Average of ratings: -
In reply to Finton Paul

Re: Aadar Theme - Can not find data record in database table context.

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Paul,

This theme seems to be flawed, although the DB tables have been added there appears to be no real way of populating that table.

The form is not working because the theme author is ussing code which he admits he does not understand.

Also the reason you get the error is that the theme is looking for an image in the DB. There appears to be a stage missing that inserts data into the datatable.

We need help with this from someone like Gareth who knows about these things!

Cheers

Mary

In reply to Finton Paul

Re: Aadar Theme - Can not find data record in database table context.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Flinton,

When you click on 'More information about this error' what does it say?

Have you contacted the author about it? -> https://moodle.org/plugins/view.php?plugin=theme_aadar

Can you turn on developer level debugging with 'display debug messages' and post what it says please -> http://docs.moodle.org/24/en/Debugging

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Aadar Theme - Can not find data record in database table context.

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Dear Gareth,

The link to the Moodle Doc is empty.

Here's the Stack Trace ...

Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => 6,
)]
Error code: invalidrecord
Stack trace:

    line 1335 of \lib\dml\moodle_database.php: dml_missing_record_exception thrown
    line 1311 of \lib\dml\moodle_database.php: call to moodle_database->get_record_select()
    line 4987 of \lib\accesslib.php: call to moodle_database->get_record()
    line 1351 of \lib\accesslib.php: call to context::instance_by_id()
    line 32 of \theme\aadar\addimage.php: call to get_context_info_array()

Cheers

Mary

In reply to Mary Evans

Re: Aadar Theme - Can not find data record in database table context.

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Dear Gareth,

This theme appears to work perfectly in Moodle 2.4.3 but not in Moodle 2.3.6 which is what I tried it on first! Hence the error - Silly me! sad

Mary

In reply to Mary Evans

Re: Aadar Theme - Can not find data record in database table context.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Mary,

I've just downloaded a copy and was about to try it out on the latest 2.4.x.  So, is the problem sorted or do I need to look?

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Aadar Theme - Can not find data record in database table context.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok,

I think I know what is going on.  Right, the issue is that the 'context id' has been hard coded in frontpage.php:

/theme/aadar/addimage.php?contextid=6&sectionid=1&userid

This is 'bad' and will cause an issue in some Moodle installations.

The addimage.php and addimage_form.php are actaully adaptations of the Grid format editimage.php and editimage_form.php as I found the same unaltered comment:

/* No idea, copied this from an example. Sets form data options but I don't know what they all do exactly */

But, the Grid format works out the context id from the course id.  And the front page is a course with $COURSE being a global it should be possible to use:

global $COURSE;

$context = context_course::instance($COURSE->id);

$contextid = $context->id;

in the frontpage.php file.

This needs to be tested.

Cheers,

Gareth

P.S. Theme code despirately needs 'code checking'.

In reply to Gareth J Barnard

Re: Aadar Theme - Can not find data record in database table context.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, this is a replacement 'frontpage.php' to test.  I understand the principle of context in Moodle but not quite sure on exact implementation at a given level.  So have changed to a course context rather than system context.  However, they both work if you extract the id from the $context variable.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Aadar Theme - Can not find data record in database table context.

by Finton Paul -

Hi Gareth

The debugging info is as follows:

Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => 6,
)]
Error code: invalidrecord
Stack trace:
  • line 1357 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1333 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 5137 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 1351 of /lib/accesslib.php: call to context::instance_by_id()
  • line 32 of /theme/aadar/addimage.php: call to get_context_info_array()
In reply to Finton Paul

Re: Aadar Theme - Can not find data record in database table context.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Finton,

Thanks smile - please use the replacement frontpage.php attached above as there is no context id '6' in your database and the author has mistakingly hard coded this.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Aadar Theme - Can not find data record in database table context.

by Niranjan eAbyas -

Thanks you for suggestions.Sorry for the inconvenience, I forgot to change it before uploading. Please download the new code from the git https://github.com/cvnniranjanreddy/moodle-theme_aadar.git. I will update the main plugin also. 

In reply to Niranjan eAbyas

Re: Aadar Theme - Can not find data record in database table context.

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Thanks for the update!

Cheers

Mary