qTranslate-Team/qtranslate-x

Random <p> and </p> tags in post editor pages

johnclause opened this issue · 3 comments

Theme: any, "Twenty Fifteen" would do.
Plugins: can be qTranslate-X only, I do not think it is a compatibility problem with other plugins.
At least two languages, for example, en and de, to be specific.

Steps to reproduce the problem:

  • Add New Post
  • Title: any, it is not a subject of the problem
  • Put Editor in "Text" mode
  • Description: type EN for "en" language and DE for "de", just as an example, any text would do.
  • Publish.
  • Go to database and see that 'post_content' field of that post has <!--:en-->EN<!--:--><!--:de-->DE<!--:-->, which is normal.
  • Open that post for editing.
  • Editor comes in "Text" mode, as it was left in "Text" mode before.
  • Switch to "Visual" mode
  • Click on description text, do not even need to do any typing, just press "Update" button right then.
  • Database now has: <!--:en--><p>EN</p><!--:--><!--:de-->DE<!--:-->, where EN was the active language at time of pressing "Update". This part is kind of explainable, TinyMCE embraced active text with <p></p>, although it does not do so, when plugin is deactivated.

But then something really strange happens:

  • click in editor again and then “Update” again, database now has:
    <!--:en--><p>EN</p><p> </p><!--:--><!--:de-->DE<!--:-->
  • And even more striking, do not click anywhere, just press “Update” again. database now has:
    <p><!--:en--><p>EN</p><p> </p><p><!--:--><!--:de-->DE<!--:--></p>
    Pay attention that <p> and </p> do not match anymore.

Further clicking “Update” does not modify this text anymore.

I have been printing various variables on java console, but those <p> did not show up anywhere I looked so far. I have no idea how they get into the database.

If people consistently keep editor at "Visual" mode, they apparently do not notice a problem. Nobody complained about this yet, but we'd better to clear it out before somebody does.

P. S. I first discovered this in the original qTranslate, and I thought that after cleaning the code, it will go away on its own, but it did not so far.

I see that some extra unmatched <p> tags coming after the line
$content = apply_filters( 'the_editor_content', $content ); in /wp-includes/class-wp-editor.php.

trunk now has a version 2.9.7b available for testing

2.9.8.0 has a fix.