[wp-forums] disappearing text on edit

Otto otto at ottodestruct.com
Thu Jan 6 09:46:14 UTC 2011


Posts are in TEXT fields in MySQL, and limited to 64k. This one is too
long, so it gets truncated. That's just the start of the limitations
here.

In displaying the edit post box, the string gets run through the
bbpress function called "bb_code_trick_reverse". This handles
processing pre and code tags and such.

The first line in this function is as follows:
$text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s",
'bb_decodeit', $text);

The "bb_decodeit" function is the callback, but that actually turns
out to be irrelevant, because it's hitting some kind of limit in PHP's
implementation of regular expressions.

I took a sample of the long post text and popped it into a text file.
Then I wrote this test code:

$start = file_get_contents('testdata.txt');
function test($a) { echo 'here'; }
$text = preg_replace_callback('!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s',
'test', $start);
var_dump($text);

By successively chopping off the end of the testdata.txt file, I have
determined that, on my test setup at least, when the testdata.txt file
is greater than 33797 bytes, $text gets set to NULL. The content of
the data doesn't seem to be relevant, it's simply too big for the
regular expression to work with. And the test function never gets
called ("here" is never displayed).

So, there's the source of the problem.

-Otto



On Thu, Jan 6, 2011 at 2:32 AM, Mr mist <listswpforum at mist.org.uk> wrote:
> A while back this issue came up where a post would vanish on edit.  It
> seemed related to the length of the post or some other factor, but wasn't
> easily reproducable.
>
> Anyway, one of you guys asked for it to be mentioned if it happened again,
> and we have an example now -
>
> http://wordpress.org/support/topic/wordpress-website-hacked-please-review
> -hackers-planted-code?replies=2
>
> As usual it's a fairly long quoted bit.  Hopefully it might be useful for
> debugging purposes.
> --
> mrmist
> _______________________________________________
> wp-forums mailing list
> wp-forums at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-forums
>


More information about the wp-forums mailing list