1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Server Issue Threads with over 50 chars in lenght turn invisible

Discussion in 'Resolved Bug Reports' started by Floren, Sep 28, 2012.

  1. Floren

    Floren Well-Known Member

    Update: This is indeed a PCRE bug, Jake was right.

    This started on the assumption certain keywords make the thread title go blank.
    After further testing, the issue is related to the number of chars present into thread title. For some reason the node title limit (50 chars) gets somehow intersected with the thread title, only when you view the thread list and only into thread title (compare line 327 with 333):


    I created a live demonstration of this nasty bug, you can follow the original thread also.
    Server setup: CentOS 6 64bits minimal install with Nginx 1.2.2, PHP 5.3.17 and MariaDB 5.2.12

    Please do not state that you cannot replicate this issue, because is there. Others users reported the same behaviour on their servers.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I don't have this problem on my forum but...

    Admin CP -> Appearance -> Templates -> thread_list_item

    The title is word wrapped at 50 characters:

    {xen:helper wrap, $thread.title, 50}
    That does some string processing including a call to preg_replace(). I have seen regex functions like this fail as a result of buggy PCRE libraries. Visit admin.php?tools/phpinfo to see what PCRE version is being used. I suggest upgrading your PCRE version to see if that fixes the problem. There are newer versions of PCRE bundled with newer versions of PHP:

  3. Floren

    Floren Well-Known Member

    Thanks Jake, I'm using PCRE 7.8, not bundled in PHP.

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There are newer versions available. Try upgrading.
    Adam Howard likes this.
  5. Floren

    Floren Well-Known Member

    Based on my experience, it is not related to that. One thing is sure, this issue made surface in 1.1.3, 1.1.2 is OK.
    I'm going to setup 2 test forums (1.1.2 and 1.1.3) on one of my dev servers and let you know. Logging into my life server is pretty hard due to security features implemented.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  7. MattW

    MattW Well-Known Member

    I've just tried this, and I'm running PCRE 8.21 and I don't have suhosin compiled. It doesn't make the thread turn invisible on my site.
  8. Insy

    Insy Well-Known Member

    I can't reproduce this bug.

    In library/XenForo/Helper/String, find:
    return preg_replace('#[^\s]{' $breakLength '}(?=[^\s])#u''$0  '$string);
    Add add before:
    return substr(trim($string), 0$breakLength);
    Does it working ?
  9. Floren

    Floren Well-Known Member

    It does work but now it cuts the extra chars:
    	public static function wordWrapString($string, $breakLength)
    		$breakLength = intval($breakLength);
    		if ($breakLength < 1 || $breakLength > strlen($string)) // strlen isn't completely accurate, but this is an optimization
    			return $string;
    		return substr(trim($string), 0, $breakLength);
    This is how it looks with the new code inserted:

    IMG_14102012_183133.png IMG_14102012_183145.png
  10. Floren

    Floren Well-Known Member

    Technically, the title "This is a random thread title with over fifty characters in length" is reduced to 50 chars and displays as "This is a random thread title with over fifty char". This is definitely not related to PCRE.
  11. Floren

    Floren Well-Known Member

  12. Jeremy P

    Jeremy P Well-Known Member

    Actually if the code Insy posted is working, which would return before the preg_replace, it could indicate the problem is on that line, no? I don't understand how you can rule out PCRE?

    Create a test file:
    function wordWrapString($string$breakLength)
    $breakLength intval($breakLength);
        if (
    $breakLength || $breakLength strlen($string)) // strlen isn't completely accurate, but this is an optimization
    preg_replace('#[^\s]{' $breakLength '}(?=[^\s])#u''$0  '$string);
    $string 'ThisIsAStringWhereThereAreLotsOfWordsWithNoSpaces';
    $breakLength 10;
    .. and run it.

    If the output is not exactly:
    ThisIsAStr ingWhereTh ereAreLots OfWordsWit hNoSpaces

    .. then the problem definitely lies somewhere in the preg_replace, which would definitely indicate a PCRE bug, or a problem with the regular expression itself. It's one or the other.
    EQnoble likes this.
  13. Floren

    Floren Well-Known Member

    Jake... I apologize, you were right. (y)
    Jeremy... many thanks for your test idea, it was a PCRE bug:
    I've made an rpm quickly for PCRE 8.21 and once I upgraded the version, the problem was solved. :eek:
    PCRE 8.3x will break things in CentOS 6, stay away from it and use 8.21 instead.
    I uploaded the rpm into Axivo repository, so others who run on CentOS 6 can fix it easy also:
    The issue does not make surface on CentOS 5 and PCRE 6.6 version.
    Insy, EQnoble, Jake Bunce and 2 others like this.
  14. Digital Doctor

    Digital Doctor Well-Known Member

Share This Page