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

Highlighting search terms in forum search text posts fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6, 1.6.1, 1.6.2, 1.6.3
    • Fix Version/s: 1.6.3, 1.7
    • Component/s: Forum
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_15_STABLE, MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE

      Description

      When searching a forum, if there are any matches in a post whose format is FORMAT_PLAIN, highlighting of terms does not work.

      The problem is caused by the forum highlighting function (mod/forum/search.php), as it is not testing wether the post to highlight is in html format. If it is not, it will add some HTML tags which will be latter stripped by forum_print_post (mod/forum/lib.php) by the format_text (lib/weblib.php) function.

      Here is a patch for the issue:
      <pre>
      +++ search.php 20 Sep 2006 12:27:16 -0000
      @@ -204,6 +204,15 @@
      //Use highlight() with nonsense tags to spot search terms in the
      //actual text content first. fiedorow - 9/2/2005
      $missing_terms = "";
      +
      + if ($post->format == FORMAT_PLAIN)

      { + $post->message = s($post->message); + $post->message = rebuildnolinktag($post->message); + $post->message = str_replace(' ', '  ', $post->message); + $post->message = nl2br($post->message); + $post->format = 1; + }

      +
      $message = highlight($strippedsearch,format_text($post->message, $post->format, NULL, $course->id),
      0,'<fgw9sdpq4>','</fgw9sdpq4>');

      </pre>

        Attachments

          Activity

            People

            • Assignee:
              vyshane Vy-Shane Sin Fat
              Reporter:
              peralta Luis Peralta
              Tester:
              Nobody
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Oct/06