Moodle
  1. Moodle
  2. MDL-23905

Embedded files within HTML resources don't migrate properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Files API
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      27174

      Description

      Hi,

      In 1.9 if I have a resource pointing to "index.html", and that file embeds images / CSS and links to other HTML files, upon upgrading the 2.0 the embedded/linked files will not be created within the resource's files area and are therefore missing.

        Activity

        Hide
        Ashley Holman added a comment -

        Complex solution: recursively crawling HTML resources for all embedded content and linked images, then creating these within the resource's files area.

        Simple solution: circumvent the security of the file API by allowing all legacy files to be accessed from "migrated" resources.

        Show
        Ashley Holman added a comment - Complex solution: recursively crawling HTML resources for all embedded content and linked images, then creating these within the resource's files area. Simple solution: circumvent the security of the file API by allowing all legacy files to be accessed from "migrated" resources.
        Hide
        Martin Dougiamas added a comment -

        Ashely, the design was that the migration is delayed for this case, and occurs the first time someone views the media file via the old file.php script.

        Can you revisit the page and check that this is happening?

        Petr, any reason why this might not be working?

        Show
        Martin Dougiamas added a comment - Ashely, the design was that the migration is delayed for this case, and occurs the first time someone views the media file via the old file.php script. Can you revisit the page and check that this is happening? Petr, any reason why this might not be working?
        Hide
        Ashley Holman added a comment -

        I tested with the latest 2.0 version and all of the embedded content was missing. BTW the paths had ".." in them, eg. "../images/blah.gif", does that make any difference?

        Also what was the idea with the delayed migration happening the upon first view? Because in many cases the content can be multi-page, so there is a Next and Prev HTML link which will load an entirely new HTML page that has its own images/stylesheets embedded. I can give you a backup file as an example.

        Show
        Ashley Holman added a comment - I tested with the latest 2.0 version and all of the embedded content was missing. BTW the paths had ".." in them, eg. "../images/blah.gif", does that make any difference? Also what was the idea with the delayed migration happening the upon first view? Because in many cases the content can be multi-page, so there is a Next and Prev HTML link which will load an entirely new HTML page that has its own images/stylesheets embedded. I can give you a backup file as an example.
        Hide
        Ashley Holman added a comment -

        The initial page of my resource is: http://mace.adl-na.netspot.com.au/testupgrade/pluginfile.php/141/mod_resource/content/0/Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_01.html

        That page has a link that points to http://mace.adl-na.netspot.com.au/testupgrade/pluginfile.php/141/mod_resource/content/0/Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_02.html

        This returns an error "Can not find data record in database table resource."

        The link to page 2 is done like this: <a href="../../../../Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_02.html"

        But also none of the images or css are present on the initial page.

        Note there can also be javascript refering to files, eg these referenced images are missing:

        onmouseout="imgSwap('next_bot','buttons/next_up.gif')" onblur="imgSwap('next_bot','buttons/next_up.gif')" onmouseover="imgSwap('next_bot','buttons/next_down.gif')" onfocus="imgSwap('next_bot','buttons/next_down.gif')">

        Show
        Ashley Holman added a comment - The initial page of my resource is: http://mace.adl-na.netspot.com.au/testupgrade/pluginfile.php/141/mod_resource/content/0/Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_01.html That page has a link that points to http://mace.adl-na.netspot.com.au/testupgrade/pluginfile.php/141/mod_resource/content/0/Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_02.html This returns an error "Can not find data record in database table resource." The link to page 2 is done like this: <a href="../../../../Imported_Resources/BSBLEG301A_IMS/content/Section_1/page_02.html" But also none of the images or css are present on the initial page. Note there can also be javascript refering to files, eg these referenced images are missing: onmouseout="imgSwap('next_bot','buttons/next_up.gif')" onblur="imgSwap('next_bot','buttons/next_up.gif')" onmouseover="imgSwap('next_bot','buttons/next_down.gif')" onfocus="imgSwap('next_bot','buttons/next_down.gif')">
        Hide
        Ashley Holman added a comment -

        Here's a really basic example: <script src="cgmain.js" type="text/javascript" language="JavaScript"></script>

        That file is not accessible via the pluginfile.php URL.

        Show
        Ashley Holman added a comment - Here's a really basic example: <script src="cgmain.js" type="text/javascript" language="JavaScript"></script> That file is not accessible via the pluginfile.php URL.
        Hide
        Petr Škoda added a comment -

        This was working for me some time ago, there is an on demand migration code that does the migration from legacy to new area during the first access. COuld you please send me backup of the course from 1.9?

        Show
        Petr Škoda added a comment - This was working for me some time ago, there is an on demand migration code that does the migration from legacy to new area during the first access. COuld you please send me backup of the course from 1.9?
        Hide
        Ashley Holman added a comment -

        Here's a suggestion: how about making pluginfile.php automatically fall back on the course/legacy files if a file is not found with a mod_resource component ?

        Show
        Ashley Holman added a comment - Here's a suggestion: how about making pluginfile.php automatically fall back on the course/legacy files if a file is not found with a mod_resource component ?
        Hide
        Ashley Holman added a comment -

        I have committed a one-liner patch which fixes this. It appears to be a regression which was breaking the on-demand migration in all cases.

        Show
        Ashley Holman added a comment - I have committed a one-liner patch which fixes this. It appears to be a regression which was breaking the on-demand migration in all cases.
        Hide
        Petr Škoda added a comment -

        great, thank you for the fix, closing

        Show
        Petr Škoda added a comment - great, thank you for the fix, closing

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: