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

Highlighting search terms in forum search text posts fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.6.3, 1.7
    • 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
    • Forum
    • None
    • Any
    • MOODLE_15_STABLE, MOODLE_16_STABLE
    • MOODLE_16_STABLE, MOODLE_17_STABLE

      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>

            vyshane Vy-Shane Sin Fat
            peralta Luis Peralta
            Nobody Nobody
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.