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

Forum posts containing links not sent

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.9, 1.9.5
    • Fix Version/s: 1.8.10, 1.9.6
    • Component/s: Forum
    • Labels:
      None
    • Environment:
      Linux i386, RHEL/CentOS 4.7 (PHP 4.3.9, MySQL 4.1.22)
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      Forum posts containing regular HTML links to external sites inside the text of the forum posting don't get sent. As far as I can tell it's the anchor tag that confuses some logic in lib/html2text.php (other HTML tags don't make trouble on my site).

      How to reproduce:

      • write forum posting
      • mark word
      • use the link button of the HTML editor and link the marked word to an arbitrary site
      • start cron.php via webbrowser to see debugging output (or wait 30+ mins)

      Results:

      • posting doesn't get sent to forum subscribers

      My observations:

      • looking at the debugging output of cron.php reveals, that the scripts stops during the forum processing stage while trying to send to the 1st subscriber of the forum with the concerning posting
      • looking in apache logfile /var/log/httpd/error_log shows that cron.php crashes with the following fatal error:
        "PHP Fatal error: Call to a member function on a non-object in /var/www/html/moodledev/lib/html2text.php on line 575"
      • in table mdl_forum_posts column 'mailed' is set to '1' for the concerning posting
      • removing the link from the posting (via regular editing of the posting), resetting the 'mailed' column to '0' and rerunning cron.php via browser sends the posting to the forum subscribers

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            francois Francois Marier added a comment -

            Thanks for reporting this Markus.

            I can confirm that it is in fact broken on PHP4, however it works fine on PHP5.

            Will look for a way to make this work on PHP4 too.

            Cheers,
            Francois

            Show
            francois Francois Marier added a comment - Thanks for reporting this Markus. I can confirm that it is in fact broken on PHP4, however it works fine on PHP5. Will look for a way to make this work on PHP4 too. Cheers, Francois
            Hide
            francois Francois Marier added a comment -

            Here is a preliminary patch for this interested in getting this fixed as quickly as possible.

            I will commit it to CVS once I have finished testing it.

            Show
            francois Francois Marier added a comment - Here is a preliminary patch for this interested in getting this fixed as quickly as possible. I will commit it to CVS once I have finished testing it.
            Hide
            francois Francois Marier added a comment -

            Fixed in CVS.

            Doesn't need to be fixed in 2.0 since we require PHP 5.

            Show
            francois Francois Marier added a comment - Fixed in CVS. Doesn't need to be fixed in 2.0 since we require PHP 5.
            Show
            dougiamas Martin Dougiamas added a comment - Thanks Francois, I added it to http://docs.moodle.org/en/Moodle_1.9.5_release_notes#Known_problems_and_regressions
            Hide
            hillig Markus Hillig added a comment -

            Francois,
            thank you very much for quickly fixing this problem. I just installed html2text.php (Ver. 1.8.26.6 from MOODLE_19_STABLE) on our site and can confirm that now everything works as expected.

            Regards,
            Markus

            Show
            hillig Markus Hillig added a comment - Francois, thank you very much for quickly fixing this problem. I just installed html2text.php (Ver. 1.8.26.6 from MOODLE_19_STABLE) on our site and can confirm that now everything works as expected. Regards, Markus
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Tested under 19_STABLE and verified the patch has fixed the problem. Thanks guys

            Show
            samhemelryk Sam Hemelryk added a comment - Tested under 19_STABLE and verified the patch has fixed the problem. Thanks guys
            Hide
            shirai Tatsuya Shirai added a comment -

            The email bodies sent by forum_cron() is broken in Japanese environment.
            The cause of this problem is utf8_encode() function in lib/html2text.php.

            refer from lib/html2text_readme.txt;

            ------(from here)---

            Modifications
            --------------

            1- fix for these warnings in cron:

            "html_entity_decode bug - cannot yet handle MBCS in html_entity_decode()!"

            by using this code:

            utf8_encode(html_entity_decode($string));

            instead of:

            html_entity_decode($string, ENT_COMPAT, 'UTF-8');

            --------(to here)------

            utf8_encode() function converts characters from ISO-8859-1 to UTF-8.
            Then, Multibyte UTF-8 characters were convereted to wrong unexpected characters...

            function _convert()
            {
            // Variables used for building the link list
            $this->_link_count = 0;
            $this->_link_list = '';

            $text = trim(stripslashes($this->html));

            // Convert <PRE>
            $this->_convert_pre($text);

            // Run our defined search-and-replace
            $text = preg_replace($this->search, $this->replace, $text);
            $text = preg_replace_callback($this->callback_search, array(&$this, '_preg_callback'), $text);

            // Replace known html entities
            // $text = utf8_encode(html_entity_decode($text));
            $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); // (Here!!!)

            // Remove unknown/unhandled entities (this cannot be done in search-and-replace block)
            $text = preg_replace('/&[^&;]+;/i', '', $text);

            Or, use mb_convert_encoding() function, please.

            Show
            shirai Tatsuya Shirai added a comment - The email bodies sent by forum_cron() is broken in Japanese environment. The cause of this problem is utf8_encode() function in lib/html2text.php. refer from lib/html2text_readme.txt; ------ (from here) --- Modifications -------------- 1- fix for these warnings in cron: "html_entity_decode bug - cannot yet handle MBCS in html_entity_decode()!" by using this code: utf8_encode(html_entity_decode($string)); instead of: html_entity_decode($string, ENT_COMPAT, 'UTF-8'); -------- (to here) ------ utf8_encode() function converts characters from ISO-8859-1 to UTF-8. Then, Multibyte UTF-8 characters were convereted to wrong unexpected characters... function _convert() { // Variables used for building the link list $this->_link_count = 0; $this->_link_list = ''; $text = trim(stripslashes($this->html)); // Convert <PRE> $this->_convert_pre($text); // Run our defined search-and-replace $text = preg_replace($this->search, $this->replace, $text); $text = preg_replace_callback($this->callback_search, array(&$this, '_preg_callback'), $text); // Replace known html entities // $text = utf8_encode(html_entity_decode($text)); $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); // (Here!!!) // Remove unknown/unhandled entities (this cannot be done in search-and-replace block) $text = preg_replace('/& [^&;] +;/i', '', $text); Or, use mb_convert_encoding() function, please.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  21/Oct/09