grid format: Error code: cannotfinduploadedimage

grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -
Number of replies: 58

Hello Gareth, Hello Tim,

I am using moodle 2.8.7 and the course format grid plugin in version 2.8.2.2 with the latest commit from Fri Jun 19 (Fix 'showavailability'.). I have a course with 17 sections. The course format of this course is confiugured for the grid format. I can see seven of the grid images but after that I've got the following error message:

Cannot find the uploaded original image. Please report error details to developer.

More information about this error

Debug info:
Error code: cannotfinduploadedimage
Stack trace:
  • line 463 of /lib/setuplib.php: moodle_exception thrown
  • line 1368 of /course/format/grid/lib.php: call to print_error()
  • line 397 of /course/format/grid/renderer.php: call to format_grid->setup_displayed_image()
  • line 123 of /course/format/grid/renderer.php: call to format_grid_renderer->make_block_icon_topics()
  • line 151 of /course/format/grid/format.php: call to format_grid_renderer->print_multiple_section_page()
  • line 281 of /course/view.php: call to require()
I updated the moodle instance from moodle 2.8.6 and course format grid in version 2.8.2.2 with the commit from Fri Apr. 3. I think until the update it worked as expected.

Do you have any idea, what is wrong and/or how I can fix this issue?

Greetings & Thanks,
Michae

Average of ratings: -
In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Michael,

Ok, firstly thanks for the stack trace, really helps.  I often update my development installations via Git but don't have the error.  One thing that springs to mind is the storage of the image and its location within the Moodle File API which has been an issue on and off over the years with unpredictable results.  I'll take what you've given me and have another look at the code to see if I can logically work out any fault + update to M2.8.7 and see if there is something in that process.

Is there anything 'odd' you've done?

Work around is to re-upload the image for the section after the one that works.

G

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

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

P.S.

Are there any errors apart from the one already stated in the php.log?

Can you add the following after line 1368 in Grid's lib.php:

error_log(get_string('cannotfinduploadedimage', 'format_grid').' SID: '.$sectionimage->sectionid.' IMG: '.$sectionimage->newimage);

Then when the error happens again it will give more information in the php.log.

Ta,

G

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

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

Ok, did what I said I was going to do and cannot replicate.  Ran cron, checked images on course, updated to M2.8.7 and images still there.  If there is an oddity then need some means of reliably replicating it such that any fix can be proven to solve the issue.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Gareth,

I added the line to the lib.php like you suggested but I am getting the same stack trace:

[Wed Jul 15 10:38:19.044576 2015] [:error] [pid 16384] [client localhost:53047] Default exception handler: Cannot find the uploaded original image.  Please report error details to developer. Debug: \nError code: cannotfinduploadedimage\n* line 463 of /lib/setuplib.php: moodle_exception thrown\n* line 1368 of /course/format/grid/lib.php: call to print_error()\n* line 397 of /course/format/grid/renderer.php: call to format_grid->setup_displayed_image()\n* line 123 of /course/format/grid/renderer.php: call to format_grid_renderer->make_block_icon_topics()\n* line 151 of /course/format/grid/format.php: call to format_grid_renderer->print_multiple_section_page()\n* line 281 of /course/view.php: call to require()\n, referer: https://localhost/moodle/course/view.php?id=6670

The teacher of the course said, that he did not do anything 'odd'! wink

At the end the work around to re-upload the image for the section after the one that works - by guessing the sectionid number - solved the problem.

Thanks a lot Gareth for your help and your excellent work!

Greetings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks Michael,

I've had a Muppet moment, so please could you put that 'error_log' on the line above the 'print_error' within the 'if' so that it gets to the php.log file for next time.

By 'odd' I mean from an site admin point of view, so in the way the site was updated.  Like 'moodledata' not moved or new site and restore from backup.  How did you exactly perform the update please?

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Gareth,


I've got the same error messages like befor.

Normaly I ugrade the moodle installation by the following steps:

- enable the maintenance mode

- backing up the moodle code

- backing up the the moodle database

- run a git pull for the mode core code

- run a git pull for all the submodules like your course_format_grid

- run the cli upgrade scipt &

- disable the maintenance mode

Thats it!

Greetings & Thanks,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks for the info Michael,

I'll need to think.  One thing though is that you are updating from the Git repository.  That is my development area and only 'tagged' versions should be used or ones on the plugins DB on moodle.org.  The development area could have bugs / partial development implementation etc.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Hi Gareth,

I'm having the same trouble in Moodle 2.8.6 (Build: 20150511), Grid Format Version 2015040300, Release 2.8.2.2, using More theme. My site is hosted by a Moodle Partner so I cannot look at the code directly and they have to vet it before implementing changes but they told me that "the grid format plugin has been updated and applied to your production site on July 2. I was on vacation when the update happened and just logged in today and discovered a course with 19 sections with Grid Format is throwing the same error that Michael reported.

I can add to what Michael said with my own discovery. I find that the Grid Format works correctly for up to 10 sections. After that, if you choose 11 (or more) sections from the Edit Settings of the course or manually add a new section using the + from the main course page with editing on, you get the error message. The problem with the error is that you cannot see the remaining sections to have the option to change the image. When you look at the source code for the page, where the error occurs, all the sections after section 11 are just missing on the main body of the page and you cannot access the sections or content from the main page anymore. However, you can navigate to the missing sections using the Navigation block.

Here's what the source HTML code looks like where error occurs (starts at section 11 (code adjusted to blind my site-specific info)):

<li role="region" aria-label="section-11">

<div data-rel="fatalerror" class="box errorbox">

<p class="errormessage">Cannot find the uploaded original image.  Please report error details to developer.</p>

<p class="errorcode"><a href="http://docs.moodle.org/28/en_us/error/format_grid/cannotfinduploadedimage">More information about this error</a></p>

</div>

<div class="continuebutton">

<form method="get" action="http://mymoodlesite/course/view.php">

<div><input type="submit" value="Continue"><input type="hidden" name="id" value="coursenumber"></div>

</form>

</div>

</li>

</ul> <!-- end class="gridicons" -->

I find that the Grid Course Format works correctly with 10 sections or less. See screenshot of Moodle 2.8.6 course with 10 sections in Grid Format working properly below (click image to view full size in new window):

Screenshot of Moodle 2.8.6 course with 10 sections in Grid Format working properly

But when I go to 11 sections (or more), I receive the error. See screenshot of Moodle 2.8.6 course with 19 sections in Grid Format throwing error below (click image to view full size in new window):

Screenshot of Moodle 2.8.6 course with 19 sections in Grid Format throwing error

I hope this information helps you find and resolve the issue soon. 

Thanks,

Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Laura,

Thank you so much!  That sort of information that pins things down to a possible way to replicate is really useful.

I have a couple of jobs on at the moment, so will get to this as soon as I can.

Kind regards,

Gareth

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Laura,

sorry, but with my setup I can't reproduce this error by adding the 11th or 12th section via the Edit Settings dialogue or via manually adding a new section using the +, like you described.

I don't get the error message again. The plugin works as expected.

Thanks & Greetings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks Michael,

I tried to replicate as well and could not.  I suspect that there could be a strange logic / set of events that cause the image not to be there but the displayedimageindex to be greater than 0 and thus the code think that there should be an image.  I'm going to think of how to change the code such that information gets written to the php.log when the image is not found but no error happens.  Then when images potentially 'disappear' then you'll be able to tell me the information in the log which will help and still have a functional course (bar having to re-upload the image).

Cheers,

Gareth

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Hi Michael,

I'm totally confused. What did you change between yesterday and today so that the plugin now works as expected? I thought you said yesterday that even with the changes Gareth suggested, it was still throwing the error?

Thanks,

Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Laura,

the suggestion of Gareth was to change the lip.php file for generating more output in the error log file, to see better what is going on. But the suggestion did not realy help.

I solved the problem by re-uploading the image to the section which caused the error. I hope it is nothing realy confing. wink

Thanks & Greetings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Thanks, Michael.

Hmmm...I cannot get to the section that is malfunctioning to change the image (the grid won't show for me to click on the Change Image link) nor can I edit the lib.php file directly (limited access by Moodle Partner). I've asked my Moodle Partner to review this discussion. Perhaps they can see what's causing the error on the back-end and make the fix.

Thanks for your help smile

Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

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

Hi all,

For the life of me whatever evil things I do to my database / moodledata folder I cannot replicate the error.  So, I've added some debug code that outputs to the php.log file.  So with Moodle 2.8, please update and install this: https://github.com/gjb2048/moodle-format_grid/releases/tag/V2.8.2.3 official version that has the following changes: https://github.com/gjb2048/moodle-format_grid/commit/a77bb14c2bf501fb6ff580cc28838e352479037b.  Or if you want, make a backup of your existing grid format and just apply the 'error_log' changes to lib.php - they will work without anything else.  And will also work with the M2.9 version.

Update: I've decided to publish both: https://moodle.org/mod/forum/discuss.php?d=316988 - so update as normal smile.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Hi Gareth,

Sorry for all the trouble. My Moodle Partner (MP) figured out how to reset the image (see below) and that solved the problem. The only thing I can think of to solve this type of problem in the future is to have the image file reset to <brokenfile> or something so that if an image that was previously available for a particular section on the grid can no longer be found, it replaces with a placeholder image so that the code doesn't break and we can still access the Change Image link.

Here's what the MP did to resolve the problem on my site:

There is a trick we use when topic sections cannot be edited: we look at the URL id-number of the previous section in edit mode and then alter the URL id-number - we replace it with a id-number greater or less than to get the non-editable section in edit mode.

What we did specifically:

In edit mode we clicked on" change image" for section 10 (last section functioning properly) and changed the URL sectionid from 205 to 204. We replaced the image and that corrected the broken layout. It took a bit of investigation - we had to look at which sectionids were available and which were missing.

Example

http://mymoodlesite/course/format/grid/editimage.php? SECTIONID=205 &contextid=1584&userid=4&role=link&aria-label=Set%20or%20change%20image

I hope this helps. Thanks for spending so much time helping me!

Best wishes,
Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Laura,

Thanks for the suggestion, its a good one and I'll think of how it could be implemented.  In the mean time, the latest version has better logging which may help to get to the cause of the problem in the first place.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Thanks, Gareth. 

I've asked my MP to update the Grid Format to include the extra logging features. Hopefully everything will work as you intended from here on out smile

Best wishes,
Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Laura,

this is exactly what I did. Thats what I meant "by guessing the sectionid number". wink

Sorry for not explain it well.

Greatings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

by Laura Gay Majerus -

Hi Michael,

I asked the MP to refer to this thread so it's possible they took your suggestion for fixing the problem wink I think I finally understand what you both did so I can do it myself to fix a break if it happens again. 

As an aside, I have often have problems with the image links breaking when I create an alias to an image in my repository rather than copying the image. Perhaps that's what happened initially to me...who knows smile

Best wishes,
Laura

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks all, need to think.  Just looked at the code and cannot find a logic fault.  Humm.  Would be interesting to know if the file is in the files table.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

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

Additional, if you want to patch the code such that upon page refresh the error message does not happen again, then in lib.php for M2.8 around line 1370, please try:

        } else {
            error_log(get_string('cannotfinduploadedimage', 'format_grid').' ConxID: '.$contextid.' CID: '.$this->courseid.' SID: '.$sectionimage->sectionid.' DIX: '.$sectionimage->displayedimageindex.' IMG: '.$sectionimage->newimage.' - Please send this information along with a dump of the \'grid_icon\', \'course_section\' and \'files\' DB tables to the developer.  Also look in the moodledata \'filedir\' folder for the \'file\' with the \'contenthash\' from the \'files\' table where the \'itemid\' is the same as the \'SID\' and \'component\' is \'course\' and \'filearea\' is \'section\' and see if it exists.');
            $DB->set_field('format_grid_icon', 'image', null, array('sectionid' => $sectionimage->sectionid));
            print_error('cannotfinduploadedimage', 'format_grid', $CFG->wwwroot . "/course/view.php?id=" . $this->courseid);
        }

As the code assumes that the file is not in the files table.

Cheers,

Gareth

In reply to Laura Gay Majerus

Re: grid format: Error code: cannotfinduploadedimage

by mike thiem -

Thanks for this it helped me with the same issue. Running moodle 2.9 and latest grid. 

In reply to mike thiem

Re: grid format: Error code: cannotfinduploadedimage

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

Update.

Did a full blown M2.8 -> M2.9 upgrade and still could not replicate.  Will try again but over time with some 'crons' in between.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Gareth,

this is the out put of the apache error log file after the upgrade to version 2.8.2.3 of your plugin:

[Mon Jul 20 17:46:23.102662 2015] [:error] [pid 6379] [client localhost:41367] Cannot find the uploaded original image.  Please report error details and the information contained in the php.log file to developer. ConxID: 388877 CID: 6670 SID: 106528 DIX: 0 IMG: goi_GoneWiththeWind1.jpg - Please send this information along with a dump of the 'grid_icon', 'course_section' and 'files' DB tables to the developer.  Also look in the moodledata 'filedir' folder for the 'file' with the 'contenthash' from the 'files' table where the 'itemid' is the same as the 'SID' and 'component' is 'course' and 'filearea' is 'section' and see if it exists., referer: https://mymoodelsite/moodle/course/view.php?id=6670&lang=en
[Mon Jul 20 17:46:23.103028 2015] [:error] [pid 6379] [client localhost:41367] Default exception handler: Cannot find the uploaded original image.  Please report error details and the information contained in the php.log file to developer. Debug: \nError code: cannotfinduploadedimage\n* line 463 of /lib/setuplib.php: moodle_exception thrown\n* line 1370 of /course/format/grid/lib.php: call to print_error()\n* line 397 of /course/format/grid/renderer.php: call to format_grid->setup_displayed_image()\n* line 123 of /course/format/grid/renderer.php: call to format_grid_renderer->make_block_icon_topics()\n* line 151 of /course/format/grid/format.php: call to format_grid_renderer->print_multiple_section_page()\n* line 281 of /course/view.php: call to require()\n, referer: https://mymoodlesite/moodle/course/view.php?id=6670&lang=en

But the first part of this message is not shown via the GUI/browser.

Thanks a lot & Greatings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks Michael,

Very interesting, humm.  Its intentional that the info is in the php.log file as would really panic a user.  So left instructions there and for persistence of data.  Is the file 'goi_GoneWiththeWind1.jpg' in your 'files' table in the DB (please use the instructions in the error message)?

A bug in M2.9 version has been reported so will fix that too!  The most common way for bugs to be reported is the day after a release.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Gareth,

I searched for the file goi_GoneWiththeWind1.jpg using the following select statements:
select * from mdl_files where filearea='section' AND component='course' AND itemid='106528';

&

select * from mdl_files where filename='goi_GoneWiththeWind1.jpg';

Sorry, but I could not find the file nor the contenthash. Also I don't know how to dump of the 'grid_icon'.

I can send you the export of the following select statements by email, if you want:

select * from mdl_course_sections where course='6670';

or

select * from mdl_course_sections where id='106528' AND course='6670';

Thanks & Greatings,

Michael

In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Michael,

Thanks for the information.  It looks like I made a mistake in the name of the 'grid_icon' table in the instructions, it should be 'format_grid_icon'.  Ok, given that the file does not appear to be in the files table then something is removing it.  I already knew that if 'filepath' was anything other than '/', such  as '/gridimage' then the file can be purged, that is why I've implemented that for the generated displayed image only.  Therefore 'format_grid_icon' knows of an image in a course that has been uploaded and is expected to be there, but... when upgrading that something removes that image in the table and perhaps the moodledata filecache too.  Problem is, what?

Can you confirm that in the course and course_sections tables that the specified course id and section id's exist please?  At the moment I don't think I need the tuple result from the select query on course_sections, thank you for offering.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Michael Wuttke -

Hello Gareth,

yes I can confirm that the specified course id and section id's exists in the course and course_sections tables. I made the select queries in a test environment with the database dump where the error occurred last time and a copy of the moodledata folder.

Thanks & Greatings,

Michael


In reply to Michael Wuttke

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks Michael, I think I'm going to have to find time to perform a complete upgrade test and see if I can replicate.  Then if so, try and work out what is going on.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

I too have had this issue in two courses over the weekend.

Staff have attempted to change the image in a grid and when  the page has saved they get the error described here.

I have found that in the database , a table named format_grid_icon has a field called displayedImageIndex.  If the image is there usually this field is set to 1 if there is no image then it is set to 0.

on the pages I am getting the error there is an image listed but it is set to 0.  So to rectify the error I reset the field back to 1 and all works well.

e.g. (the image with the red box is the erroneous item)



In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks for the information Wes.

Ok, I have never been able to replicate this.  I have been trying by having one course import into another - grid to grid, I've not tried non-grid to grid yet.

I appears that the original file is somehow being lost but not the displayed image file which is created from the latter and hence the whole displayedimageindex mechanism.

As soon as there is a way of reliably replicating the issue I will be in a position to see what the problem is and hopefully put in a fix.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

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

Ok, still stumped.

I've tried importing both grid and non-grid based courses into courses with grid images, backups / restores, upgrades.... and I still cannot replicate this.  Getting really frustrated!

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Jari Vilkman -

Hello,


Have you tried using Internet Explorer? We have managed to replicate the problem with Internet Explorer when adding a picture to the grid section.

In reply to Jari Vilkman

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Jari,

Thanks for the info.  I've not tried IE as its a server side issue, but will try.  So, IE11?  And just upload an image then you get the error?

Cheers,

Gareth

In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

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

Wes, does the file 'goi_planning.png' appear in the 'files' table?  Along with the others listed that don't have the problem?  That information would be helpful.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

Sorry for the delay getting back to you Gary.  Its the start of a new year for us and its a bit manic smile

I didn't check anywhere else other than the table I mentioned.. I don't have access to our Moodle back end at the moment but when / if the issue happens again I will check and get back to you.

Wes


In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

Hi Gareth

Some info you asked for smile

I have attached some database images and put the filedir in this text.  

I think the file is registered in the database but when I broke the pathnamehash down to find the image in the filedir folder it wasn't there. I may have not done this bit right though smile






Attachment db1.png
Attachment db2.png
In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

This is what one of the working images database entries looks like

And some feed back from the tutors is that this is occurring when they are changing the title of the grid not changing the image.

Hope this helps

Wes

Attachment db3.png
In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks for the information Wes, I'll see if I can replicate.  The database entries look correct.  Does the 'file hash' lead to a file in the moodledata folder? See: https://docs.moodle.org/dev/File_API_internals#File_storage_on_disk to help.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

Your Welcome. 

In answer to your question about the filehash - I dont think there is a file hash, I meant to write 'pathnamehash' which does link to a file in the filedirfolder smile

Thanks for the supporting documentation.

In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

by Daniel Dubbeldam -

I had a similar error on one of our sites and came to the following:


when in mdl_format_grid_icon the displayedimageindex (DII) = "0", and the image is viewed in the course, it changes to "1".
However, if in a course, the DII = "0" and this section is not VISIBLE  (or does not exist), it will remove the name of the image.


F.E.
I had a course, which had 6 entry's in "mdl_format_grid_icon". 4 of them had DII ="1" and 2 had DII ="0".
I went to the course in Moodle, and had 4 sections, which were clearly visible. 
After adding 1 extra section, I had a clearly visible icon, which was the one stated in the table with DII="0".
The status of this image changed from 0 to 1.

The last image however, the resulting image with status "0". had been emptied. 

in (database) pictures:

status on forehand:


After visiting the page, no changes.

After adding 1 section it was as follows:



as you can see, ID 3580 has been emptied.


after adding the last section (so that "plaatje 1.jpg" should be visible) there was no picture, and the database says (total overview with all images):



hopefully this helps resolving the matter.

With Kind Regards,

Daniel Dubbeldam
Customer Support Avetica.

In reply to Daniel Dubbeldam

Re: grid format: Error code: cannotfinduploadedimage

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

Hi Daniel,

Thanks for the information.  After an hour of trying to replicate I cannot.  There is no way I can simulate id '3580' sort of thing being cleared unless the number of sections is reduced.  Visibility of the section has no affect on the image name (or anything else) grid related in the database.  I've tried with TDM off and no developer debugging, filenames with spaces, using IE, altering the DII to '0' manually in the DB and then showing the course as a student for the first time with a hidden section and then as an admin.  The code works as expected with the image being regenerated and shown.

What concerns me in the example is the lack of 'goi_' (grid original image) prefix which was added to avoid conflict when uploading an image which was also used in the section as well.  In your example, the 'plaatje 1.jpg' image must be from an older version of the format and not uploaded in the course of testing.

One thing I did discover when removing / adding sections is that Moodle uses a new section id for a given section if you remove it then add it again, but the format retains the older id and adds a new one leaving redundant records in the database.

Kind regards,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Gareth, we found a reproducing methode (by accident).

The issue that appeared was that the teacher was unable to remove ór change the image in grid.
Daniel checked the database but the displaying was as it supposed to with "1".

To force the removing of the images, he deleted them out of the Database.
Refreshing the course gave directly the error that we been seeing before

Regretfully the error - even though Daniel added the code to the log - doesn't appear in any logs.

For your information: the teachers work with Mozilla Firefox and not IE.


=> What you noticed "plaatje 1.jpg" image is indeed out of an older version. THe site has been updated from 2.6 to 2.9 recently.

In reply to Gemma Lesterhuis

Re: grid format: Error code: cannotfinduploadedimage

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

Thanks Gemma.

I can replicate the error if indeed the database is manually hacked, the original image entry in the files table is removed then the DII is set to zero in the format_grid_icon table.  Then upon second refresh, the code sorts things out such that the course will display without the image.  I am then able to upload a new image without error.  But... this is hardly a situation that the code does.  There is nothing that currently explains why the original image in the 'course / section' root filepath of the files table is removed?

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Replicated the error "Image not found" by doing following:

1) Make new course

2) set course to gridcoursformat, 10 sections

3) Import a standard course that is made in grid, 10 sections,
In this course you have
NO ERROR while importing

4) Imported activities and sources out of an old course to this new build course.
Error while importing, image not found.

I was able to avoid the error by importing the old activities and sources before  I imported the standaard.

As well as making sure that before  I imported the standaard that I had the same number of sections as well as that sections that "where" mising in where added to it.

In this course it ment I had to add a section 11, and move this section between the orginal sections 1 en 2, since in the standaard there was a named section "Docenten" which wasn't in the old course.


In reply to Gemma Lesterhuis

Re: grid format: Error code: cannotfinduploadedimage

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

Hi all,

With help from Gemma I have been able to replicate the issue.

It appears that when importing certain courses that the 'files' table is not populated with the images from the source course but the 'format_grid_icon' table is.  The latter is under my control as a part of the restore / import process, the former is not.  I don't know why it is happening even with the knowledge of section names being the same but with a section in the middle being different in one course.  One set of courses in this process replicates it, when I set up an apparently same set of courses I cannot replicate the error.  At all times I am able to upload new icons and repair the damage.

Currently, the code will self heal in the 'format_grid_icon' table.  Thus if you remove the error message line that halts display of the course (https://github.com/gjb2048/moodle-format_grid/commit/f5bab0361d4e0f8574e1dde27cb5ffaff2a57b71#diff-828043dc9f8d10ccd58ff8b96297794fL1462) then this will happen for you too.  Ok, fair enough, you will have to re-upload replacement icons, but this only seems to happen every now and then at times when you'll be updating anyway.

Please do let me know how things go and if you have any new information that could shed greater light on this issue.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Tested 2.9.1.5 fix and it worked - no errors.

It skipped the images that aren't take with the import, and image that are in the import I am able to change and delete without any errors.


Thank you so much for your time and effort!

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

Maybe a silly question bout I'll ask anyway.

We have recently upgraded Moodle to 2.8.6.  Can we use the 2.9 version of the grid format in Moodle 2.8?

Wes

In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

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

It may or may not work.  However I do state in the readme that a given version only supports a given major version of Moodle.  i.e. "This version works with Moodle version 2015051100.00 2.9 (Build: 20150511) and above within the 2.9 branch until the next release."  And why would you want to anyway?

Update: It should actually fail to install because of what has been set in the version.php file.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Wes Sykes -

I was only asking because others have been mentioning the fix in grid version 2.9 but nothing was mentioned about fixing the 2.8 version.

Wes

In reply to Wes Sykes

Re: grid format: Error code: cannotfinduploadedimage

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

Oh ok, I'll get around to the M2.8 version at some point.

In reply to Gareth J Barnard

Re: grid format: Error code: cannotfinduploadedimage

by Sarah Ricketts -

Hi Gareth,

We're experiencing exactly the same issue, v 2.8.2.3 on Moodle 2.8.7+ and temporarily 'fixing' the issue by guessing the section number and re-adding a temp image.  Is there any other fix we can apply or are you still investigating it?

Thanks

Sarah

In reply to Michael Wuttke

(Re:) Grid format: Error with images after update

by Antti Peltonen -

Hi,

I updated the Grid format and the Moodle is 2.9.2.  (I think). I got the Error message:

Internal Server Error

File "/MYSERVER/moodle/course/format/grid/editimage.php" is writeable by group

I just did compare file rights on a server with other format files and changed 666 to 664 -It fixed the problem.

It seems that the code is OK but the update procedure did set the file rights wrong (?)

Hope that helps, if you face the same situation.


-Antti-


In reply to Antti Peltonen

Re: (Re:) Grid format: Error with images after update

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

Thanks for the information Antti.

What update procedure did you follow?  As the Grid instructions state 755 for folders and 644 for files.

The latest M2.9 is: 2.9.1+ (Build: 20150806) (2015051101.05) - so M2.9.2 does not exist yet.