Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-25219

@@PLUGINFILE@@ replacing href link in HTML editor.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2
    • Component/s: HTML Editor (TinyMCE)
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Hi Petr,

      Would just like to add an issue I came across on one particular site but could not replicate on my own site.

      I spoke to Tim about this as it was occurring in the quiz module but he informed me it was an issue with the HTML editor and that you had the best knowledge on how it worked.

      Here is what was happening. Entries in a quiz question contained href links referencing a file on the server, such as href="draftfile.php/1/2/somefile.swf", however the link would be formatted with the term @@PLUGINFILE@@ when viewing the html source. Very odd. The solution was to edit the question and delete the URL (make it blank - href="") saving the changes, then re-editing the question and adding the URL again. The only way I can see why this is fixing the issue is if a bug caused these links to be saved incorrectly, and if not altered it is never updated.

      Sorry I can't be of more help on this issue.

      Regards,

      Mark

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            skodak Petr Skoda added a comment -

            I can not reproduce this, sorry. The editor dos simple search replace before and after text editing, I do not think there is a bug in file and editor code.

            Show
            skodak Petr Skoda added a comment - I can not reproduce this, sorry. The editor dos simple search replace before and after text editing, I do not think there is a bug in file and editor code.
            Hide
            markn Mark Nelson added a comment -

            Hi Petr,

            I started debugging the code myself as it was occurring too often and the fix I mentioned earlier was working sporadically. The questiontext column in the question table was being saved with @@PLUGINFILE@@ so I began looking through the code and saw that a few question types save_function called the parent function in the file question/type/questiontype.php. Here lies the issue, this uses a function called file_save_draft_area_files in lib\filelib.php. This is where the string '@@PLUGINFILE@@' is being inserted. I have not looked into this further as I was hoping someone from Moodle HQ with more familiarity with the filelib code would be able to discover if there is an issue in the actual code or not.

            Show
            markn Mark Nelson added a comment - Hi Petr, I started debugging the code myself as it was occurring too often and the fix I mentioned earlier was working sporadically. The questiontext column in the question table was being saved with @@PLUGINFILE@@ so I began looking through the code and saw that a few question types save_function called the parent function in the file question/type/questiontype.php. Here lies the issue, this uses a function called file_save_draft_area_files in lib\filelib.php. This is where the string '@@PLUGINFILE@@' is being inserted. I have not looked into this further as I was hoping someone from Moodle HQ with more familiarity with the filelib code would be able to discover if there is an issue in the actual code or not.
            Hide
            markn Mark Nelson added a comment -

            So far, commenting on the line //$text = str_ireplace($draftbase, '@@PLUGINFILE@@/', $text); in that function mentioned above is working, though I am not sure of the potential issues this may cause in other areas of the site!

            Show
            markn Mark Nelson added a comment - So far, commenting on the line //$text = str_ireplace($draftbase, '@@PLUGINFILE@@/', $text); in that function mentioned above is working, though I am not sure of the potential issues this may cause in other areas of the site!
            Hide
            skodak Petr Skoda added a comment -

            The links to draft files must be replaced with the @@PLUGINFILE@@, so most probably the problem is that some code does not replace the plugin file marker before the display.

            Reassigning to author of original quiz/questions conversion.

            Show
            skodak Petr Skoda added a comment - The links to draft files must be replaced with the @@PLUGINFILE@@, so most probably the problem is that some code does not replace the plugin file marker before the display. Reassigning to author of original quiz/questions conversion.
            Hide
            markn Mark Nelson added a comment -

            Hi Petr,

            Merry Christmas.

            Just wondering if there was any update on this?

            Show
            markn Mark Nelson added a comment - Hi Petr, Merry Christmas. Just wondering if there was any update on this?
            Hide
            markn Mark Nelson added a comment -

            I have investigated this issue more, and realised this issue occurs for the description question type, but the others I have tried work.

            I initially thought that in the file question/type/description/questiontype.php the line in the function print_question "$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);" was not actually replacing the @@PLUGINFILE@@. However, inspecting other question types I noticed that the $question->questiontext variable should already have the correct URL. So the issue lies with not formatting $question->questiontext before it is passed to the print_question function.

            Show
            markn Mark Nelson added a comment - I have investigated this issue more, and realised this issue occurs for the description question type, but the others I have tried work. I initially thought that in the file question/type/description/questiontype.php the line in the function print_question "$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);" was not actually replacing the @@PLUGINFILE@@. However, inspecting other question types I noticed that the $question->questiontext variable should already have the correct URL. So the issue lies with not formatting $question->questiontext before it is passed to the print_question function.
            Hide
            markn Mark Nelson added a comment - - edited

            Attached a patch: created by the one and only Sam Hemelryk - a patch that resolves this issue afaik.

            Show
            markn Mark Nelson added a comment - - edited Attached a patch: created by the one and only Sam Hemelryk - a patch that resolves this issue afaik.
            Hide
            markn Mark Nelson added a comment -

            Also, just thought I would add that the behaviour varies between the question types. Some save the URL in the database, where as the description (and possibly others) store the URL as @@PLUGINFILE@@ and are then responsible for filtering the URL when displayed. Why?

            Show
            markn Mark Nelson added a comment - Also, just thought I would add that the behaviour varies between the question types. Some save the URL in the database, where as the description (and possibly others) store the URL as @@PLUGINFILE@@ and are then responsible for filtering the URL when displayed. Why?
            Hide
            dongsheng Dongsheng Cai added a comment -

            Mark

            Files and content are separated in moodle 2, moodle will find the related associated files by contextid, itemid, filearea and filename, @@PLUGINFILE@@ will be replaced by above parameters.

            Show
            dongsheng Dongsheng Cai added a comment - Mark Files and content are separated in moodle 2, moodle will find the related associated files by contextid, itemid, filearea and filename, @@PLUGINFILE@@ will be replaced by above parameters.
            Hide
            dongsheng Dongsheng Cai added a comment -

            Pull request submitted PULL-81

            Thanks to Sam's patch, it looks good.

            Show
            dongsheng Dongsheng Cai added a comment - Pull request submitted PULL-81 Thanks to Sam's patch, it looks good.
            Hide
            mudrd8mz David Mudrak added a comment -

            Tested. Dongsheng, please see the comment in the pull request.

            Show
            mudrd8mz David Mudrak added a comment - Tested. Dongsheng, please see the comment in the pull request.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  21/Feb/11