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

Searching courses for multiple words removes spaces between them in result list

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.9.5
    • Component/s: Course
    • Labels:
      None

      Description

      If you enter multiple words in the "search courses" box, when the results are displayed and the words appear next to one another in the course summary, the spaces between those words are removed. Its much easier to see than explain, and visible on Moodle.org (see url field).

      I'm not sure what other versions of Moodle this might affect. It appears to be buried deep in the format_text function, but I can't work out exactly what's doing it.

        Gliffy Diagrams

          Activity

          Hide
          dougiamas Martin Dougiamas added a comment -

          Hmmm ... my guess is the highlighting function ..

          Show
          dougiamas Martin Dougiamas added a comment - Hmmm ... my guess is the highlighting function ..
          Hide
          mrbriz James Brisland added a comment -

          Hi Martin,

          Just some notes as I have dug into this issue a little.

          It's not a problem with the highlighting code, it seems to surface inside the format_text function.

          Thie highlightling is applied before each of the courses are output in search.php

          [code]
          ($course->summary = highlight("$search", $course->summary);
          [/code]

          If you echo out the summary text after here it displays correctly.

          The course then gets passed into print_course() and inside print course the summary is passed into format_text()

          [code]
          echo format_text($course->summary, FORMAT_MOODLE, $options, $course->id);
          [/code]

          If you change FORMAT_MOODLE to FORMAT_HTML it seems to fix the problem. I have looked into format_text() and can't find where the error is happening, so instead of going crazy I thought I'd pass this info onto an expert

          Hope this helps resolve the issue.

          Regards,

          James Brisland.

          Show
          mrbriz James Brisland added a comment - Hi Martin, Just some notes as I have dug into this issue a little. It's not a problem with the highlighting code, it seems to surface inside the format_text function. Thie highlightling is applied before each of the courses are output in search.php [code] ($course->summary = highlight("$search", $course->summary); [/code] If you echo out the summary text after here it displays correctly. The course then gets passed into print_course() and inside print course the summary is passed into format_text() [code] echo format_text($course->summary, FORMAT_MOODLE, $options, $course->id); [/code] If you change FORMAT_MOODLE to FORMAT_HTML it seems to fix the problem. I have looked into format_text() and can't find where the error is happening, so instead of going crazy I thought I'd pass this info onto an expert Hope this helps resolve the issue. Regards, James Brisland.
          Hide
          mrbriz James Brisland added a comment - - edited

          Hi Anyone that's watching this thread,

          I have a fix for this, but I'm not sure if it's correct.

          As I mentioned above if you change FORMAT_MOODLE to FORMAT_HTML in the format_text call inside the print_course function this fixes the issue.

          I think the issue is that FORMAT_MOODLE calls text_to_html on the text passed in which messes up any spans which were put in by the highlighting functions.

          If this is the correct fix do you want me to patch it to the current latest CVS branch (HEAD?)

          Regards,

          James Brisland

          Show
          mrbriz James Brisland added a comment - - edited Hi Anyone that's watching this thread, I have a fix for this, but I'm not sure if it's correct. As I mentioned above if you change FORMAT_MOODLE to FORMAT_HTML in the format_text call inside the print_course function this fixes the issue. I think the issue is that FORMAT_MOODLE calls text_to_html on the text passed in which messes up any spans which were put in by the highlighting functions. If this is the correct fix do you want me to patch it to the current latest CVS branch (HEAD?) Regards, James Brisland
          Hide
          jenny-gray Jenny Gray added a comment -

          Just retested with 1.9.1 and this problem has gone away! I think the new fast highlighting function is better.

          Show
          jenny-gray Jenny Gray added a comment - Just retested with 1.9.1 and this problem has gone away! I think the new fast highlighting function is better.
          Hide
          jerome Jérôme Mouneyrac added a comment -

          Failed on 1.9 Stable

          Connect as a student (you can not see summary when you do a course search as Admin)
          Go to http://yourserver/yourmoodle/course/search.php?search=first_param+second_param (one of your course summary contains "first_param" followed by "second_param")
          The summary will highlight "first_paramsecond_param"

          Show
          jerome Jérôme Mouneyrac added a comment - Failed on 1.9 Stable Connect as a student (you can not see summary when you do a course search as Admin) Go to http://yourserver/yourmoodle/course/search.php?search=first_param+second_param (one of your course summary contains "first_param" followed by "second_param") The summary will highlight "first_paramsecond_param"
          Hide
          jenny-gray Jenny Gray added a comment -

          rats, yes. My mistake.

          Jame's fix above still definitely works though. Would you be OK if I commit that now? Its been working on our site with no related bugs reported for a year now

          Show
          jenny-gray Jenny Gray added a comment - rats, yes. My mistake. Jame's fix above still definitely works though. Would you be OK if I commit that now? Its been working on our site with no related bugs reported for a year now
          Hide
          skodak Petr Skoda added a comment -

          works fine for me now, thanks

          Show
          skodak Petr Skoda added a comment - works fine for me now, thanks

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/May/09