WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Search Unleashed] problem after 2.7 upgrade (15 posts)

  1. tubalreversal
    Member
    Posted 5 years ago #

    I have just upgraded to wordpress 2.7 and am getting Warning: Missing argument 2 for mb_strlen() in /usr/home/blog/wp-content/plugins/search-unleashed/search-unleashed.php on line 698. Please advise.

  2. doctorkaraca
    Member
    Posted 5 years ago #

    Editing search-unleashed.php and changing line 699 as follows temporarily works for me as I wait for the next update of the plugin.

    Find the line that goes:

    function mb_strlen ($str, $encoding)

    and replace it with:

    function mb_strlen ($str)

    I hope I am not breaking anything. But as I said, it's a temp solution and it works for me.

  3. Michael Torbert
    WordPress Virtuoso
    Posted 5 years ago #

    That variable checks the database to see the charset you have, ie UTF-8. Though the search may work fine for you if it disregards the setting, you possible haven't set that option for your WordPress installation.

    Check your wp-config.php, is your charset set to utf8?

  4. doctorkaraca
    Member
    Posted 5 years ago #

    Following line exists in my wp-config.php

    define('DB_CHARSET', 'utf8');

    If I don't change the search-unleashed.php as I mentioned above, I cannot add or edit any posts. After the change however, I am able to post new entries and edit existing posts whose titles don't exceed 30 characters or so... Wierd.

    My host is using PHP 4.4.7 still. I wonder if I am missing out on some important new PHP functionality.

  5. tubalreversal
    Member
    Posted 5 years ago #

    Thanks 'doctorkaraca' editing search-unleashed.php to function mb_strlen ($str) worked for me.

    We also have php version 4.4.7 and wp-admin/options-reading.php is set to UTF-8

  6. tubalreversal
    Member
    Posted 5 years ago #

    I may have spoken too soon i now see a similar error on the wp-admin/post.php page and have deactivated again.

  7. tubalreversal
    Member
    Posted 5 years ago #

    I tried
    function mb_strlen ($str, $encoding = "base64")
    this got rid of the error on edit.php but it is still there on post.php

  8. tomchen1989
    Member
    Posted 5 years ago #

    =================STEP 1===================
    open the file search-unleashed.php (line 697-703 for v0.2.24),
    replace this:

    if (!function_exists ('mb_strlen'))
    {
    	function mb_strlen ($str, $encoding)
    	{
    		return strlen ($str);
    	}
    }

    with:

    if (!function_exists ('mb_strlen'))
    {
    	function mb_strlen1 ($str, $encoding)
    	{
    		return strlen ($str);
    	}
    }

    =================STEP 2===================
    then open the file models\search-unleashed.php (line 21 for v0.2.24),
    replace this:

    $this->first_match = mb_strlen ($this->text, get_option ('blog_charset'));

    with:

    if (!function_exists ('mb_strlen')){
    			$this->first_match = mb_strlen1 ($this->text, get_option ('blog_charset'));
    		}else{
    			$this->first_match = mb_strlen ($this->text, get_option ('blog_charset'));
    		}
  9. tomchen1989
    Member
    Posted 5 years ago #

    FOR THE STEP 1: if you want more exact, replace that with:

    if (!function_exists ('mb_strlen'))
    {
    	function mb_strlen1 ($str, $encoding) {
    		if ($encoding=='UTF-8') {
    			return preg_match_all('%(?:
    					  [\x09\x0A\x0D\x20-\x7E]           # ASCII
    					| [\xC2-\xDF][\x80-\xBF]            # non-overlong 2-byte
    					|  \xE0[\xA0-\xBF][\x80-\xBF]       # excluding overlongs
    					| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
    					|  \xED[\x80-\x9F][\x80-\xBF]       # excluding surrogates
    					|  \xF0[\x90-\xBF][\x80-\xBF]{2}    # planes 1-3
    					| [\xF1-\xF3][\x80-\xBF]{3}         # planes 4-15
    					|  \xF4[\x80-\x8F][\x80-\xBF]{2}    # plane 16
    					)%xs',$str,$out);
    		}else{
    			return strlen($str);
    		}
    	}
    }
  10. tomchen1989
    Member
    Posted 5 years ago #

    this problem is caused by the lack of mbstring module, so you can also install the mbstring module to solve the problem.

  11. doctorkaraca
    Member
    Posted 5 years ago #

    tomchen1989 you are genius and my hero. Your instructions above works wonderfully. One minor thing,

    $this->first_match = mb_strlen ($this->text, get_option ('blog_charset'));

    is not in models\search-unleashed.php but in models\highlighter.php.

    Thanks a lot.

  12. tomchen1989
    Member
    Posted 5 years ago #

    oops, my mistake...:)

  13. tubalreversal
    Member
    Posted 5 years ago #

    Thanks guys works for me :)

  14. phbyerly
    Member
    Posted 5 years ago #

    Love this search, but it's causing problems with making posts. Posts save just fine, but I end up with a totally blank page with URL/wp-admin/post.php - no error message, just an empty page. Same thing when I edit a post - it changes, but I get a blank page.

    I tried the two changes suggested above by tomchen1989, it did not help.

  15. Eric P
    Member
    Posted 5 years ago #

    Nice catch tomchen1989. I used your fix interim.

    The author has since fixed this issue in version Version: 0.2.27. I was having the same problem and this version works for me.

Topic Closed

This topic has been closed to new replies.

About this Topic