Moodle
  1. Moodle
  2. MDL-3721

Wiki add extra empty div blocks at each edit

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6, 1.6.5, 1.7.3, 1.8.3
    • Fix Version/s: 1.9
    • Component/s: None
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      27598

      Description

      If I create wiki page, containing the following HTML text:

      <ol>

      <li>Something</li>

      </ol>

      Then save page and edit it. Page will appear as

      <div class=indent style=margin-left: 15px;></div>

      <ol>

      <li>Something</li>

      </ol>

      [three new line characters]

      If I save page again it will become:

      <div class=indent style=margin-left: 15px;></div>

      <div style=margin-left: 15px; class=indent></div>

      <ol>

      <li>Something</li>

      </ol>

      [six new line characters]

      Every time I edit the page one div and three new line characters are added. If the page is more complicated (list have more elements), more emplty div blocks and more new line characters are added each time

      1. wikibug.html
        0.8 kB
        Tony Hursh
      1. moodle_bug.gif
        71 kB

        Activity

        Hide
        Tony Hursh added a comment -

        The same issue affects table elements. We had a wiki page with a medium-sized table in it, and noticed this problem after the page became very slow to load. It had thousands of extraneous div tags in it.

        Show
        Tony Hursh added a comment - The same issue affects table elements. We had a wiki page with a medium-sized table in it, and noticed this problem after the page became very slow to load. It had thousands of extraneous div tags in it.
        Hide
        Tony Hursh added a comment -

        If the attached file is pasted into the code view of a wiki, it will generate 9 extra div tags each time the page is loaded and resaved.

        Show
        Tony Hursh added a comment - If the attached file is pasted into the code view of a wiki, it will generate 9 extra div tags each time the page is loaded and resaved.
        Hide
        Martin Dougiamas added a comment -

        I think a lot of this is due to the html editor ... try switching it off for that wiki.

        Show
        Martin Dougiamas added a comment - I think a lot of this is due to the html editor ... try switching it off for that wiki.
        Hide
        Jeffery Watkins added a comment -

        So, the current wiki cannot use the HTML editor without problems?

        Show
        Jeffery Watkins added a comment - So, the current wiki cannot use the HTML editor without problems?
        Hide
        Clif Kussmaul added a comment -

        I'm having the same problem in Moodle 1.6.1.
        In one case the file got so big it wouldn't load, and I had to edit it via the database

        I'm not a Moodle or PHP guru, but it looks to me like the extra divs
        might be getting generated in ewiki.php, line 1918:

            • indentation (space/tab markup)
              $n_indent = 0;
              if (Unable to render embedded object: File ($list && () not found.$s["block"]) && ($n_indent = strspn($line, " ")))
              Unknown macro: { $n_indent = (int) ($n_indent / 2.65); while ($n_indent > $s["indent"]) { $out .= $wm_indent; $s["indent"]++; } }

              while ($n_indent < $s["indent"])

              { $out .= "</div>\n"; $s["indent"]--; }

        I'll try to figure out:
        a) if this is actually causing the problem
        b) the reason(s) for inserting these tags
        c) whether it can be fixed easily

        Clif

        Show
        Clif Kussmaul added a comment - I'm having the same problem in Moodle 1.6.1. In one case the file got so big it wouldn't load, and I had to edit it via the database I'm not a Moodle or PHP guru, but it looks to me like the extra divs might be getting generated in ewiki.php, line 1918: indentation (space/tab markup) $n_indent = 0; if ( Unable to render embedded object: File ($list && () not found. $s ["block"] ) && ($n_indent = strspn($line, " "))) Unknown macro: { $n_indent = (int) ($n_indent / 2.65); while ($n_indent > $s["indent"]) { $out .= $wm_indent; $s["indent"]++; } } while ($n_indent < $s ["indent"] ) { $out .= "</div>\n"; $s["indent"]--; } I'll try to figure out: a) if this is actually causing the problem b) the reason(s) for inserting these tags c) whether it can be fixed easily Clif
        Hide
        Clif Kussmaul added a comment -

        I've looked some more, and ewiki.php doesn't seem to be causing the problem.
        My current guess is that the extra DIVs are injected by the HTML editor, but I don't see where or how.
        Clif

        Show
        Clif Kussmaul added a comment - I've looked some more, and ewiki.php doesn't seem to be causing the problem. My current guess is that the extra DIVs are injected by the HTML editor, but I don't see where or how. Clif
        Hide
        Kyle P added a comment -

        I've experienced the same issue, with a wiki page not loading due to ~10000 extra div tags after the 30th or so edit. The two things that seem to cause it for me are any use of tables, and certain uses of the justification buttons. For example, when I do a left justify, a center justify, a right justify, a center justify, a left justify, and then a full justify, the html generated (pre submission) is this:

        left<br />
        <div style="text-align: center;">center<br />
        <div style="text-align: right;">right<br />
        <div style="text-align: center;">center<br />
        <div style="text-align: left;">left<br />
        <div style="text-align: justify;">full<br /></div></div></div></div></div>

        after selecting edit and save one time, without making any changes myself, the html is this:

        <div class="indent" style="margin-left: 15px;">
        <div class="indent" style="margin-left: 15px;">
        <div class="indent" style="margin-left: 15px;">left<br />
        <div style="text-align: center;">center<br />
        <div style="text-align: right;">right<br />
        <div style="text-align: center;">center<br />
        <div style="text-align: left;">left<br />
        <div style="text-align: justify;">full<br /></div></div></div></div></div> </div></div></div>

        This issue is not limited to 1.6; I am running 1.7.1+ with a build from (or around) 1/29/07.

        Show
        Kyle P added a comment - I've experienced the same issue, with a wiki page not loading due to ~10000 extra div tags after the 30th or so edit. The two things that seem to cause it for me are any use of tables, and certain uses of the justification buttons. For example, when I do a left justify, a center justify, a right justify, a center justify, a left justify, and then a full justify, the html generated (pre submission) is this: left<br /> <div style="text-align: center;">center<br /> <div style="text-align: right;">right<br /> <div style="text-align: center;">center<br /> <div style="text-align: left;">left<br /> <div style="text-align: justify;">full<br /></div></div></div></div></div> after selecting edit and save one time, without making any changes myself, the html is this: <div class="indent" style="margin-left: 15px;"> <div class="indent" style="margin-left: 15px;"> <div class="indent" style="margin-left: 15px;">left<br /> <div style="text-align: center;">center<br /> <div style="text-align: right;">right<br /> <div style="text-align: center;">center<br /> <div style="text-align: left;">left<br /> <div style="text-align: justify;">full<br /></div></div></div></div></div> </div></div></div> This issue is not limited to 1.6; I am running 1.7.1+ with a build from (or around) 1/29/07.
        Hide
        Kyle P added a comment -

        Upgraded to 1.8.1+ from 4/16/07 and it is still an issue.

        Show
        Kyle P added a comment - Upgraded to 1.8.1+ from 4/16/07 and it is still an issue.
        Hide
        chris dennison added a comment -

        This has been a faily serious issue for me. Admin staff are set up to edit college information stored as wikis. Much of the information is in table form. After a few edits the time taken to save edited pages was painful.

        I deduced moodle added a <div....> line each edit for each table line.

        I inserted a test " if(s$["tbl"] != 1 )" before the section identified by cliff above and so if $s["tbl"] did = 1 the whole section is bypassed.

        This seems to fix the symptoms .

        Perhaps someone with ewiki engine knowledge can find the bug.

        Show
        chris dennison added a comment - This has been a faily serious issue for me. Admin staff are set up to edit college information stored as wikis. Much of the information is in table form. After a few edits the time taken to save edited pages was painful. I deduced moodle added a <div....> line each edit for each table line. I inserted a test " if(s$ ["tbl"] != 1 )" before the section identified by cliff above and so if $s ["tbl"] did = 1 the whole section is bypassed. This seems to fix the symptoms . Perhaps someone with ewiki engine knowledge can find the bug.
        Hide
        chris dennison added a comment -

        Ooops I had a typo.

        The code I had was if(s$["tbl" != 1] ) so I guess the indent code never executes.... However it has fixed my problem

        Show
        chris dennison added a comment - Ooops I had a typo. The code I had was if(s$ ["tbl" != 1] ) so I guess the indent code never executes.... However it has fixed my problem
        Hide
        D.I. von Briesen added a comment -

        Having this same issue on a 1.8 installation at ISP Dreamhost. Causing lots of ill will with a teacher workshop - use BB at their schools, and use this to put down moodle- even though BB doesn't even HAVE a wiki...

        d.i.

        Show
        D.I. von Briesen added a comment - Having this same issue on a 1.8 installation at ISP Dreamhost. Causing lots of ill will with a teacher workshop - use BB at their schools, and use this to put down moodle- even though BB doesn't even HAVE a wiki... d.i.
        Hide
        Timo Leder added a comment -

        We have the same problem with Moodle 1.8.2. Its a very serious issue for us, because the wiki is a killer-app for many users... untill they get aware of this bug!

        Show
        Timo Leder added a comment - We have the same problem with Moodle 1.8.2. Its a very serious issue for us, because the wiki is a killer-app for many users... untill they get aware of this bug!
        Hide
        Timo Leder added a comment -

        thats what it leads to...

        Show
        Timo Leder added a comment - thats what it leads to...
        Hide
        Michael Spall added a comment -

        In Moodle 1.8.2+ updated from CVS this Friday, we have this issue, but only with tables in the wiki. We get one pair of div tags per table row. Lists don't seem to cause a problem. I don't think it is the HTML editor, because I turned off the HTML editor, and it still happened. Also, it doesn't happen in other areas where you type into an HTML editor, e.g., forums, quiz questions, resource descriptions.

        Show
        Michael Spall added a comment - In Moodle 1.8.2+ updated from CVS this Friday, we have this issue, but only with tables in the wiki. We get one pair of div tags per table row. Lists don't seem to cause a problem. I don't think it is the HTML editor, because I turned off the HTML editor, and it still happened. Also, it doesn't happen in other areas where you type into an HTML editor, e.g., forums, quiz questions, resource descriptions.
        Hide
        Stuart Anderson added a comment -

        And again, this issue has hit me too and the "one pair of div tags per table row" from Michael would sound about right for what I am seeing. The fix by Chris Dennison did seem to resolve the problem, though I guess I should correct his typo. Just enclose the offending block with:

        if($s["tbl" != 1] )

        { ... offending block ... }

        (Chris's $ and s were the wrong way around)

        There did appear to be a side-effect to this fix in that if a block of text has indentation applied to it, the browser complains about an HTML editor javascript problem. If you allow the javascript to continue, it does the right thing. Overall I think that the side effect is less of a problem than the tables and wiki problem which is potentially a complete blocker. I this basis I would suggest this bug is upgraded to either Major or Blocker.

        Show
        Stuart Anderson added a comment - And again, this issue has hit me too and the "one pair of div tags per table row" from Michael would sound about right for what I am seeing. The fix by Chris Dennison did seem to resolve the problem, though I guess I should correct his typo. Just enclose the offending block with: if($s ["tbl" != 1] ) { ... offending block ... } (Chris's $ and s were the wrong way around) There did appear to be a side-effect to this fix in that if a block of text has indentation applied to it, the browser complains about an HTML editor javascript problem. If you allow the javascript to continue, it does the right thing. Overall I think that the side effect is less of a problem than the tables and wiki problem which is potentially a complete blocker. I this basis I would suggest this bug is upgraded to either Major or Blocker.
        Hide
        Mauno Korpelainen added a comment -

        I had never before used wiki, but this bug looked so interesting I had to test.

        If you write:

        <table>
        <tr>
        <td>
        <ol>
        <li>whatever1</li>
        <li>whatever2</li>
        <li>whatever3</li>
        </ol>
        </td>
        </tr>
        </table>

        HTMLAREA adds INDENT so that after you have pressed save button the text looks like

        <table><tbody>
        <tr>
        <td>
        <ol>
        <li>whatever1 </li>
        <li>whatever2 </li>
        <li>whatever3 </li>
        </ol>
        </td>
        </tr></tbody>
        </table

        This happens only when you use htmlarea - test without editor. Now file mod/wiki/ewiki/ewiki.php and line "wm_indent" => '<div style="margin-left:15px;" class="indent">' (and some other lines of code) add those div tags. The same happens also without editor if you copy text that has those indents already.

        Show
        Mauno Korpelainen added a comment - I had never before used wiki, but this bug looked so interesting I had to test. If you write: <table> <tr> <td> <ol> <li>whatever1</li> <li>whatever2</li> <li>whatever3</li> </ol> </td> </tr> </table> HTMLAREA adds INDENT so that after you have pressed save button the text looks like <table><tbody> <tr> <td> <ol> <li>whatever1 </li> <li>whatever2 </li> <li>whatever3 </li> </ol> </td> </tr></tbody> </table This happens only when you use htmlarea - test without editor. Now file mod/wiki/ewiki/ewiki.php and line "wm_indent" => '<div style="margin-left:15px;" class="indent">' (and some other lines of code) add those div tags. The same happens also without editor if you copy text that has those indents already.
        Hide
        Michael Spall added a comment -

        I can confirm Mauno's findings. I must have been copying and pasting table code with the indents in it when testing without the html editor.

        Show
        Michael Spall added a comment - I can confirm Mauno's findings. I must have been copying and pasting table code with the indents in it when testing without the html editor.
        Hide
        Mauno Korpelainen added a comment -

        The same happens with TinyMCE and FCKEditor too. Cleaning all those indent tags from mod/wiki/ewiki/ewiki.php (I just noticed Clif's previous message) should solve this bug but does it change the behaviour of ewiki itself ?

        Show
        Mauno Korpelainen added a comment - The same happens with TinyMCE and FCKEditor too. Cleaning all those indent tags from mod/wiki/ewiki/ewiki.php (I just noticed Clif's previous message) should solve this bug but does it change the behaviour of ewiki itself ?
        Hide
        Mauno Korpelainen added a comment -

        If you change in lib/editor/htmlarea/htmlarea.php

        HTMLArea.__sindentChar = (typeof sindentChar == "undefined") ? " " : sindentChar;

        to

        HTMLArea.__sindentChar = (typeof sindentChar == "undefined") ? "" : sindentChar;

        then htmlarea does not add those indents itself. This does not fix the whole problem because it is still possible to copy and paste some text that has indents and then mod/wiki/ewiki/ewiki.php keeps adding those div tags. I tried to clean indent tags in mod/wiki/ewiki/ewiki.php too but the result was unexpected "Headers were already send" error ???

        Show
        Mauno Korpelainen added a comment - If you change in lib/editor/htmlarea/htmlarea.php HTMLArea.__sindentChar = (typeof sindentChar == "undefined") ? " " : sindentChar; to HTMLArea.__sindentChar = (typeof sindentChar == "undefined") ? "" : sindentChar; then htmlarea does not add those indents itself. This does not fix the whole problem because it is still possible to copy and paste some text that has indents and then mod/wiki/ewiki/ewiki.php keeps adding those div tags. I tried to clean indent tags in mod/wiki/ewiki/ewiki.php too but the result was unexpected "Headers were already send" error ???
        Hide
        chris dennison added a comment -

        Hi- how do we get this bug raised in priority??

        Show
        chris dennison added a comment - Hi- how do we get this bug raised in priority??
        Hide
        Michael Spall added a comment -

        I have updated this issue to reflect that it effects versions up to latest 1.9. I have increased the priority because it does cause a major loss of functionality, unless the user knows not to use indented html in the wiki.

        Show
        Michael Spall added a comment - I have updated this issue to reflect that it effects versions up to latest 1.9. I have increased the priority because it does cause a major loss of functionality, unless the user knows not to use indented html in the wiki.
        Hide
        Mauno Korpelainen added a comment -

        OK - in mod/wiki/ewiki/ewiki.php changing (or cleaning if you like) the following lines (removing div tags)fixes this bug:

        1)

            • rendering ruleset
              "wm_indent" => '<div style="margin-left:15px;" class="indent">',

        change to

            • rendering ruleset
              "wm_indent" => '',

        2)

        while ($n_indent < $s["indent"])

        { $out .= "</div>\n"; $s["indent"]--; }

        change to

        while ($n_indent < $s["indent"])

        { $out .= ""; $s["indent"]--; }

        3)

            • indentation
              while ($s["indent"]) { $out .= "</div>"; $s["indent"]--; }

        change to

            • indentation
              while ($s["indent"]) { $out .= ""; $s["indent"]--; }

        Those problems I had before with headers sent came from editing the file with notepad. Editing the file with Wordpad was ok and no more extra tags added (editing htmlarea.php is not necessary but if we do not need extra indends it could be cleaned too.

        Show
        Mauno Korpelainen added a comment - OK - in mod/wiki/ewiki/ewiki.php changing (or cleaning if you like) the following lines (removing div tags)fixes this bug: 1) rendering ruleset "wm_indent" => '<div style="margin-left:15px;" class="indent">', change to rendering ruleset "wm_indent" => '', 2) while ($n_indent < $s ["indent"] ) { $out .= "</div>\n"; $s["indent"]--; } change to while ($n_indent < $s ["indent"] ) { $out .= ""; $s["indent"]--; } 3) indentation while ($s ["indent"] ) { $out .= "</div>"; $s["indent"]--; } change to indentation while ($s ["indent"] ) { $out .= ""; $s["indent"]--; } Those problems I had before with headers sent came from editing the file with notepad. Editing the file with Wordpad was ok and no more extra tags added (editing htmlarea.php is not necessary but if we do not need extra indends it could be cleaned too.
        Hide
        Mauno Korpelainen added a comment -

        Ludo,
        could you verify and close this bug? Cleaning that

        <div style="margin-left:15px;" class="indent">

        and those </div>\n and </div>

        from mod/wiki/ewiki/ewiki.php seems to work perfect (tested in moodle 1.6-1.9 )

        Show
        Mauno Korpelainen added a comment - Ludo, could you verify and close this bug? Cleaning that <div style="margin-left:15px;" class="indent"> and those </div>\n and </div> from mod/wiki/ewiki/ewiki.php seems to work perfect (tested in moodle 1.6-1.9 )
        Hide
        Ludo ( Marc Alier) added a comment -

        OK,
        I'll take a look into it

        Show
        Ludo ( Marc Alier) added a comment - OK, I'll take a look into it
        Hide
        Dan Marsden added a comment -

        that patch is now in HEAD and 1.9Stable - thanks for the patch Mauno! - (attributted grigory in the cvs commit sorry! - should have been you!)

        thanks!

        Dan

        Show
        Dan Marsden added a comment - that patch is now in HEAD and 1.9Stable - thanks for the patch Mauno! - (attributted grigory in the cvs commit sorry! - should have been you!) thanks! Dan

          People

          • Votes:
            13 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: