WordPress.org

Forums

Antispam Bee
[resolved] Use of ob_start() causes no output to print (5 posts)

  1. akarmenia
    Member
    Posted 2 years ago #

    Hi,
    You've used ob_start() on line 1151 of the plugin in the prepare_comment_field() function, which is activated with this action:

    add_action(<br />
    	'template_redirect',<br />
    	array(<br />
    		__CLASS__,<br />
    		'prepare_comment_field'<br />
    	)<br />
    );<br />

    The problem is that there seems to be an incompatibility with this and my own plugin Crayon Syntax Highlighter. As far as I know using ob_start() needs you to call ob_end_flush() at some point according to http://php.net/manual/en/function.ob-start.php.

    The result is that the page doesn't load at all. I use ob_start() for logging purposes but call ob_end_flush() soon afterwards in the same function:

    crayon_log.class.php:
    ob_start();
    var_dump($var);
    $buffer = trim(strip_tags(ob_get_clean()));

    I've removed this and just used strval() for now to avoid the conflict.

    http://wordpress.org/extend/plugins/antispam-bee/

  2. akarmenia
    Member
    Posted 2 years ago #

    I've found and fixed the issue. It seems Crayon was modifying the text in the html which your code was trying to change (to modify the comments textarea). Crayon changed the content of the page enough to break the preg_replace into returning NULL (even though it's supposed to do that on errors, I wasn't able to catch any)... In any case, this modified version appears to work:

    public static function replace_comment_field($data)
    {
    	/* Leer? */
    	if ( empty($data) ) {
    		return $data;
    	}
    
    	/* Convert */
    	$newData = preg_replace(
    		'#<textarea([^<]+)name=["\']comment["\'](.+?)</textarea>#',
    		'<textarea$1name="' .self::$_secret. '"$2</textarea><textarea name="comment" style="display:none" rows="1" cols="1"></textarea>',
    		$data,
    		1
    	);
    	if ($newData !== NULL) {
    		return $newData;
    	} else {
    		return $data;
    	}
    }

    I modified it by only returning the result of the preg_replace if it wasn't NULL - but then I noticed that Crayon was causing it to always return NULL (hence the original issue). Crayon has its own textarea, and I suspect this may be the cause. I modified the regex you use to ensure that there are no tags in between <textarea and name= and likewise for the other bits to ensure that it's capturing a single textarea. It seems to be working now. Please confirm this.

  3. nicoh88
    Member
    Posted 2 years ago #

    Hi Sergej, ich bin der, der das Problem mit dem Crayon Syntax Highlighter und deinem Plugin Antispam Bee hat.

    Dieses Problem tritt nur mit einem bestimmten Artikel auf, der Artikel wird einfach nicht geladen - Seite bleibt weiß.

    In der neuen Version (2.5.4) ist das Problem leider auch noch nicht gelöst. Ich habe daher meine antispam_bee.php wieder selber angepasst!

    Ich stelle dir gerne ein SQL-Dump zur Verfügung, damit du es nachvollziehen kannst - meld dich einfach.

    Gruß Nico

  4. nicoh88
    Member
    Posted 2 years ago #

    Hi Sergej, mit der Version 2.5.7 geht es auch ohne meine händische Codeanpassung. Danke

    Gruß

  5. Sergej Mller
    Member
    Posted 1 year ago #

    Super ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Antispam Bee
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.