• I upgraded to Version 3.4 on our multiuser/networked WordPress site. The root WordPress installation is in a subfolder in public_html, and the networked blogs are in subfolders (not subdomains). Then I upgraded to WP Super Cache 1.1. Then I got several wp-super-cache warning messages. So I duplicated our site on a test xampp on my laptop (which I’ve done many times). I get the same warning/notice messages:

    Warning: strpos() [function.strpos]: Offset not contained in string in C:\xampp\htdocs\wp\wp-content\plugins\wp-super-cache\wp-cache-base.php on line 26

    Notice: Undefined variable: cache_wptouch in C:\xampp\htdocs\wp\wp-content\plugins\wp-super-cache\plugins\wptouch.php on line 109

    I googled the strpos() phrase and found a large number of active websites with the same warning messages. This is worrisome. So I disabled wp super cache on our live website.

    On my test xampp, I added a space between the ” on line 26 of wp-cache-base.php and this got rid of the Warning message.
    Here is the original code:
    $blogcacheid = str_replace( $base, '', $request_uri );
    Here is my edited code:
    $blogcacheid = str_replace( $base, ' ', $request_uri );

    I also added a similar space on line 49 of wp-cache-config.php and got rid of that warning message.
    Here is the original code:
    $blogcacheid = str_replace( $base, '', $request_uri );
    Here is my edited code:
    $blogcacheid = str_replace( $base, ' ', $request_uri );

    I would like to know if this is a safe hack for my site, and is adding a space between the ” assigned to $blogcacheid a possible remedy for the many websites found in my google search. I have never changed any of the core code.

    Thank you in advance for any help.

    http://wordpress.org/extend/plugins/wp-super-cache/

Viewing 11 replies - 1 through 11 (of 11 total)
  • No, it’s the next line that causes the problem. I’ll add some code that checks the length of $blogcacheid.

    Can you restore the code to what it was before for me and debug it? I’d like to know what $blogcacheid was before line 26. Something like this will log that to the file /tmp/err.txt but you could put it in whatever file you want.

    error_log( $_SERVER[ 'REQUEST_URI' ] . " $blogcacheid\n", 3, "/tmp/err.txt" );

    Put that on the line just before the str_replace. Thanks!

    Thread Starter cherty

    (@cherty)

    Thank you for your quick reply. Sorry it’s taken so long to get back.

    I reinstalled the WordPress site on my test xampp server, then network activated WP Super Cache. With debug on from the wp-config.php file, these two messages displayed in the browser:

    Warning: strpos() [function.strpos]: Offset not contained in string in C:\xampp\htdocs\wp\wp-content\plugins\wp-super-cache\wp-cache-base.php on line 26

    Notice: Undefined variable: cache_wptouch in C:\xampp\htdocs\wp\wp-content\plugins\wp-super-cache\plugins\wptouch.php on line 109

    After setting caching on and using mod_rewrite, I added your error_log code to the plugins/wp-super-cache/wp-cache-base.php file (lines 19 through 28, sorry about indents below):

    } else {
    		$request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
    		if( strpos( $request_uri, '/', 1 ) ) {
    			if( $base == '/' ) {
    				$blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 );
    			} else {
    			  error_log( $_SERVER[ 'REQUEST_URI' ] . " $blogcacheid\n", 3, "err.txt" );  // test code added 6-20-12
    				$blogcacheid = str_replace( $base, '', $request_uri );
    				$blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) );
    			}

    I visited these pages:
    1. Homepage
    2. Homepage Dashboard
    3. Network Dashboard
    4. Homepage
    5. Blog Site
    6. Blog site Dashboard
    7. Homepage

    Here is the err.txt output for the pages I visited:

    /wp/ blog
    /wp/bcc-news/ blog
    /wp/ blog
    /wp/bcc-news/ blog
    /wp/ztest/ blog
    /wp/ztest/page-1/ blog
    /wp/ blog
    /wp/bcc-news/ blog

    Thanks.

    Thread Starter cherty

    (@cherty)

    Thanks, I appreciate that. Can you change the error_log so it records $base and $request_uri too? Something like this should be enough:
    `error_log( “$request_uri $base $blogcacheid\n”, 3, “/tmp/err.txt” );

    Thanks!

    Thread Starter cherty

    (@cherty)

    Thanks. Here is what I added (lines 19 through 29):

    } else {
    		$request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
    		if( strpos( $request_uri, '/', 1 ) ) {
    			if( $base == '/' ) {
    				$blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 );
    			} else {
    			  //error_log( $_SERVER[ 'REQUEST_URI' ] . " $blogcacheid\n", 3, "err.txt" );  // test code added 6-20-12
    				error_log( "$request_uri $base $blogcacheid\n", 3, "err.txt" ); // test code added 6-21-12
    				$blogcacheid = str_replace( $base, '', $request_uri );
    				$blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) );
    			}

    Here is how I navigated:
    Login, Homepage, Homepage Dashboard, Network Dashboard, Homepage, Blog Site, Blog Site Dashboard, Homepage

    Here is the output to err.txt:

    /wp/wp-login.php /wp/ blog
    /wp/wp-login.php /wp/ blog
    /wp/wp-login.php /wp/ blog
    /wp/wp-login.php /wp/ blog
    /wp/ /wp/ blog
    /wp/ /wp/ blog
    /wp/bcc-news/ /wp/ blog
    /wp/bcc-news/ /wp/ blog
    /wp/ /wp/ blog
    /wp/bcc-news/ /wp/ blog
    /wp/ztest/ /wp/ blog
    /wp/ztest/ /wp/ blog
    /wp/ztest/page-1/ /wp/ blog
    /wp/ztest/page-1/ /wp/ blog
    /wp/ /wp/ blog
    /wp/bcc-news/ /wp/ blog

    Note – The Test Cache works fine, and the two lines of cache code appear at the bottom of web pages using View Source.

    Not sure if I am giving you what you want to see.
    Thanks for all your help.

    Thread Starter cherty

    (@cherty)

    I just tried the development version and it seemed to work well on my test website. The if statement on Line 28 seems to have solved my problem:

    if ( $blogcacheid != '' )
        $blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) );

    The dev version is at http://downloads.wordpress.org/plugin/wp-super-cache.zip and was referenced on another forum item that you posted (http://wordpress.org/support/topic/plugin-wp-super-cache-issue-with-scheduled-posts-not-showing-up).

    Debug on and php_error_log showed no errors. Test cache works fine and the two statements at the bottom of View Source pages display fine.

    Thanks so much, Donncha.

    I’ve got the same error on line 109:

    Undefined variable: cache_wptouch in /MYDOMAIN/wp-content/plugins/wp-super-cache/plugins/wptouch.php on line 109

    What should I do?

    It also seems to have a conflict with WP super cache but both plugin leave me a blank page on their own page.

    Thanks for the help.

    AllyV4 – it’s a harmless warning but it’s fixed in the development version.

    You can install it from this zip file:

    http://downloads.wordpress.org/plugin/wp-super-cache.zip

    Thank you πŸ™‚

    I also have this issue, but I would like to avoid using development versions. Do you maybe know when you will release the next official version of WP Super Cache?

    anec – just try the dev version. I haven’t changed anything in it in weeks and it’s very stable. It’ll possibly be the new stable version soon, but I just need to find time to release it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WP Super Cache] wp super cache Warning: strpos() [function.strpos]: Offset not contained in’ is closed to new replies.