Bizarre /cache/ experience with wp_object_cache.lock

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
I just had a rather strange experience with the object cache.  I just  
moved my site to a new server, and I deleted the contents of the /wp-
content/cache/ directory before moving.  At the new host, I was  
getting 80+ queries on my front page (redundant option hits).  I  
chown/chmod'd my /cache/ directory into oblivion... I was confident  
that I had it set correctly... but nothing.  Then, out of  
desperation, I started moving files from another WP install's cache  
into my cache.  Once I moved wp_object_cache.lock into my /cache/  
directory, it started working.

I took out all the error suppressing @s from /wp-includes/cache.php  
in an effort to try to get it to throw an fopen() error, but it  
didn't make a peep.  If /cache/ wasn't there, it wouldn't be created,  
even though the permissions were set up so that it could.

Why can't WordPress create this file?  Why wasn't WordPress reverting  
to the old caching method (i.e. select all options where autoload =  
'1' and store them in memory for that load)?

Debian 3.1
PHP4 as Apache2 module
Safe Mode OFF
--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Ryan Boren
Mark Jaquith wrote:

> I just had a rather strange experience with the object cache.  I just  
> moved my site to a new server, and I deleted the contents of the /wp-
> content/cache/ directory before moving.  At the new host, I was  getting
> 80+ queries on my front page (redundant option hits).  I  chown/chmod'd
> my /cache/ directory into oblivion... I was confident  that I had it set
> correctly... but nothing.  Then, out of  desperation, I started moving
> files from another WP install's cache  into my cache.  Once I moved
> wp_object_cache.lock into my /cache/  directory, it started working.
>
> I took out all the error suppressing @s from /wp-includes/cache.php  in
> an effort to try to get it to throw an fopen() error, but it  didn't
> make a peep.  If /cache/ wasn't there, it wouldn't be created,  even
> though the permissions were set up so that it could.
>
> Why can't WordPress create this file?  Why wasn't WordPress reverting  
> to the old caching method (i.e. select all options where autoload =  '1'
> and store them in memory for that load)?


We were seeing this with safe_mode enabled, which is why the cache is
now disabled if safe_mode is on.  What happens in the safe_mode case is
that WP thinks it can write because is_writable() returns true.  The
cache isn't really writable, however, and later attempts to write to the
cache fail.  We don't revert to the old method because is_writable() is
telling us that we are able to write to the cache even though that isn't
the case.

Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Michel Valdrighi
> > Why wasn't WordPress reverting
> > to the old caching method (i.e. select all options where autoload =  '1'
> > and store them in memory for that load)?

> We don't revert to the old method because is_writable() is
> telling us that we are able to write to the cache even though that isn't
> the case.

I haven't had time to dive into the code yet (doh), but what if there
were a check done in addition to is_writable(), to see if the first
time we try to cache something it really works? If the result of the
test is negative, revert to memory store.

--
Michel Valdrighi
Devéloppeur Web Intraordinaire
http://zengun.org/weblog/
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
On Feb 3, 2006, at 4:14 AM, Michel Valdrighi wrote:

> what if there
> were a check done in addition to is_writable(), to see if the first
> time we try to cache something it really works? If the result of the
> test is negative, revert to memory store.

Sounds good to me.  Only thing is that we'll have to create an option  
for it... and that'll add a query to every page (as it will be run  
before you grab the options from the object cache or do the autoload  
options query).  And the option will probably have to have an  
interface to change it, in case someone fixes the situation with  
safe_mode.

I still would like to know what was up with my situation (no  
safe_mode, wp-content was writable)... oh well.
--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

David House
On 03/02/06, Mark Jaquith <[hidden email]> wrote:
> Sounds good to me.  Only thing is that we'll have to create an option
> for it... and that'll add a query to every page (as it will be run
> before you grab the options from the object cache or do the autoload
> options query).  And the option will probably have to have an
> interface to change it, in case someone fixes the situation with
> safe_mode.

We don't need an option. At the moment we have a constant,
ENABLE_CACHE, which you can define in wp-config.php to enable the
cache even when safe mode is on.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
On Feb 3, 2006, at 6:02 AM, David House wrote:

> At the moment we have a constant,
> ENABLE_CACHE, which you can define in wp-config.php to enable the
> cache even when safe mode is on.

We'll still need an option if we want to automatically disable the  
cache when it isn't working an avoid those 300+ query loads.  The  
average user (a) isn't going to know that 300 queries are being made)  
and (b) probably won't figure out very quickly how to do define
('DISABLE_CACHE', true); to revert to the old cache method.

--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

David Chait
+1  Given the 'marginal gains', and given that it does absolutely freaky
things if it is in a bad state (one case was caught, you've hit another),
object caching should be DISABLED by default, and require enabling by an
advanced user (given 'average' shared hosting user won't see much of a
gain -- say compared to the wp-cache factors...).

----- Original Message -----
From: "Mark Jaquith" <[hidden email]>
To: <[hidden email]>
Sent: Friday, February 03, 2006 7:00 AM
Subject: Re: [wp-hackers] Bizarre /cache/ experience with
wp_object_cache.lock


| On Feb 3, 2006, at 6:02 AM, David House wrote:
|
| > At the moment we have a constant,
| > ENABLE_CACHE, which you can define in wp-config.php to enable the
| > cache even when safe mode is on.
|
| We'll still need an option if we want to automatically disable the
| cache when it isn't working an avoid those 300+ query loads.  The
| average user (a) isn't going to know that 300 queries are being made)
| and (b) probably won't figure out very quickly how to do define
| ('DISABLE_CACHE', true); to revert to the old cache method.
|
| --
| Mark Jaquith
| http://txfx.net/
|
|
| _______________________________________________
| wp-hackers mailing list
| [hidden email]
| http://lists.automattic.com/mailman/listinfo/wp-hackers
|

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Ryan Boren
In reply to this post by Mark Jaquith
Mark Jaquith wrote:

> On Feb 3, 2006, at 6:02 AM, David House wrote:
>
>> At the moment we have a constant,
>> ENABLE_CACHE, which you can define in wp-config.php to enable the
>> cache even when safe mode is on.
>
>
> We'll still need an option if we want to automatically disable the  
> cache when it isn't working an avoid those 300+ query loads.  The  
> average user (a) isn't going to know that 300 queries are being made)  
> and (b) probably won't figure out very quickly how to do define
> ('DISABLE_CACHE', true); to revert to the old cache method.

You can't really use options from the cache because the cache is loaded
before everything except wpdb.  You could do a direct SELECT, but
get_option() is not available.

Maybe we should simply disable persistent caching by default and let
those who want it and know they can use it turn it on.  I'm getting
tired of working around safe_mode and all of the other issues.

Ryan
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Aaron Brazell
>

> You can't really use options from the cache because the cache is loaded
> before everything except wpdb.  You could do a direct SELECT, but
> get_option() is not available.
>
> Maybe we should simply disable persistent caching by default and let
> those who want it and know they can use it turn it on.  I'm getting
> tired of working around safe_mode and all of the other issues.
>
> Ryan
>
>
Hear, hear. I for one have disabled it on all of the blogs I use and/or
maintain because it has given me nothing but headaches. Then, coming from
the perspective of a blogging network that has had a number of server
issues, once you get into moving directories and/or servers it causes more
than the average amount of heartburn.

-aaron

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
In reply to this post by Ryan Boren
On Feb 3, 2006, at 6:33 PM, Ryan Boren wrote:

> Maybe we should simply disable persistent caching by default and  
> let those who want it and know they can use it turn it on.  I'm  
> getting tired of working around safe_mode and all of the other issues.

+1

The speed gain isn't huge.  I like that it's there, and that there is  
a system in place for putting in your own systems (Memcached, APC),  
but in the end, it's more trouble than it is worth, having it enabled  
by default.

--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

David Chait
In reply to this post by Ryan Boren
:) Heh.  I already pointed that out and gave my +1.  Mark's a +2, you make
it a +3.  Go for it!

-d

----- Original Message -----
From: "Ryan Boren" <[hidden email]>
To: <[hidden email]>
Sent: Friday, February 03, 2006 6:33 PM
Subject: Re: [wp-hackers] Bizarre /cache/ experience with
wp_object_cache.lock


| Maybe we should simply disable persistent caching by default and let
| those who want it and know they can use it turn it on.  I'm getting
| tired of working around safe_mode and all of the other issues.

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Ryan Boren
David Chait wrote:
> :) Heh.  I already pointed that out and gave my +1.  Mark's a +2, you make
> it a +3.  Go for it!


http://trac.wordpress.org/changeset/3504


> ----- Original Message -----
> From: "Ryan Boren" <[hidden email]>
> To: <[hidden email]>
> Sent: Friday, February 03, 2006 6:33 PM
> Subject: Re: [wp-hackers] Bizarre /cache/ experience with
> wp_object_cache.lock
>
>
> | Maybe we should simply disable persistent caching by default and let
> | those who want it and know they can use it turn it on.  I'm getting
> | tired of working around safe_mode and all of the other issues.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

WP_Rewrite query

Rob-67
In reply to this post by Aaron Brazell
I'm trying to hook into the rewrite rules, in order to allow /library/
to display my-plugin.php?library=true, but I'm running into some problems.

I'm currently modifying the rewrite rules using Ryan's code from the codex:

------------
function nr_mod_rewrite($wp_rewrite) {
   
    $rules = array(
        'library/?' => 'wp-content/plugins/my-plugin.php?library=true'
    );
   
    $wp_rewrite->rules = $rules + $wp_rewrite->rules;
   
}
add_filter('generate_rewrite_rules', 'nr_mod_rewrite');
------------

but it just displays the index page of the site, entries and all. The
library/? match is certainly working, since going to /blah/ gives a 404,
but I discovered that the rewrite will only work if you're rewriting to
index.php; this works, for example:

------------
$rules = array(
        'library/?' => 'index.php?p=1'
);
------------

...displaying the first post in my blog when you visit /library/. I
thought then that I could just redirect to "index.php?library=true", and
then hook into init() to check $_GET['library'] and do what I want if it
was set, but no dice; it never seems to pass the variable in the query
string, as var_dump()ing $_GET gives an empty array every time.

I'm totally stumped - either this is totally the wrong way to achieve
what I want to achieve, or I'm just being inordinately stupid. Can
anyone help? Is there some easier way of redirecting that I'm totally
missing?
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
In reply to this post by Ryan Boren
On Feb 3, 2006, at 10:20 PM, Ryan Boren wrote:

> David Chait wrote:
>> :) Heh.  I already pointed that out and gave my +1.  Mark's a +2,  
>> you make it a +3.  Go for it!
>
>
> http://trac.wordpress.org/changeset/3504

Lines 407 and 408 are redundant... we don't need to bother checking  
safe mode if we're already disabling it by default

> 403          if ( ! defined('ENABLE_CACHE') )
> 404            return;
> 405
> 406        // Disable the persistent cache if safe_mode is on.
> 407        if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
> 408                     return;

--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WP_Rewrite query

Jamie Talbot
In reply to this post by Rob-67
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rob wrote:
> I'm trying to hook into the rewrite rules, in order to allow /library/
> to display my-plugin.php?library=true, but I'm running into some problems.
>  

Rob,

Some people have found this link helpful:

www.fabriziotarizzo.org/cache/query_redirect_rewrite.phps

Don't know if that's code you've already seen?  You probably need to have a rewrite_rules filter
and a query_vars filter.  You can hook into parse_query to check if a variable has been passed (like
library=true, for instance.  You can search this mailing archive for some other people that have had
this problem and some other possible solutions.

As a side note, there seem to be quite a few people having difficulty using the rewrite API at the
moment.  Perhaps this is another area we could look to improve on in 2.1?

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD5D3erovxfShShFARAhA9AJ0XQQbRB7t6nfs/RjsXeUT2XpgZAQCeNMdg
YRaPmTqz9sDDFsX76temg/Q=
=AE1t
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Jamie Talbot
In reply to this post by Mark Jaquith
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark Jaquith wrote:

> Lines 407 and 408 are redundant... we don't need to bother checking
> safe mode if we're already disabling it by default

We should still disable it for people who turn it on even though they are in safe mode, shouldn't we?

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD5D57rovxfShShFARAsrEAJwOMmL877Jsf9W1osyPe3ji4ShOPQCfX3GI
ks3EpUdybQeTFE5plgzbgAI=
=JbL/
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

multiple blog conundrum

JARRET NETSPC
Hi everyone,

I'm completely new to the list and I'm hoping to find an answer to a
question I could not resolve via WP support or Codex. Any help would be
greatly appreciated.

I need to run a number of blogs on separate sub-domains and databases.
However, the branding (with the exception of the header) will be the
same for all of them as will be the functionality where plugins etc are
concerned. I am wondering whether it is possible for the separate blogs
to reference a central theme and plugins folder so that changes made in
these folders are automatically propagated through all the blogs?

Thanks in advance,

Jarret
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WP_Rewrite query

Andy Skelton
In reply to this post by Rob-67
On 2/3/06, Rob <[hidden email]> wrote:
> but I discovered that the rewrite will only work if you're rewriting to
> index.php

Right. Wp_rewrite is not a replacement for mod_rewrite. It only
rewrites internally. To rewrite to other scripts without mod_rewrite
would require browser redirection. By keeping its scope limited to
index.php, we never have to redirect the browser.

> ...displaying the first post in my blog when you visit /library/. I
> thought then that I could just redirect to "index.php?library=true", and
> then hook into init() to check $_GET['library'] and do what I want if it
> was set, but no dice; it never seems to pass the variable in the query
> string, as var_dump()ing $_GET gives an empty array every time.

First, the init action is earlier than wp(), the function that
eventually calls $wp->parse_request(), the function that checks the
request against the wp_rewrite rules.

Second, wp_rewrite isn't going to recognize your query var unless you
add it to the public_query_vars array. There's a filter for that in
classes.php line 1584: query_vars.

Third, you're not going to find it in $_GET because WP doesn't
populate that with wp_rewrite query vars. Instead they get put in
$wp->query_vars.

Fourth and last, why bother with wp_rewrite when all you need to do is
check the request URI for your pattern and take over if it matches? I
don't know what your plugin is meant to do but I can tell you this: if
your "library" action doesn't need to modify the posts query, you can
forget about wp_rewrite.

Fifth and not even in the list, I disclaim all responsibility for the
forgoing nonsense and any consequences for putting same into practice,
real or imagined. ;-)

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple blog conundrum

Andy Skelton
In reply to this post by JARRET NETSPC
On 2/4/06, JARRET NETSPC <[hidden email]> wrote:
> I need to run a number of blogs on separate sub-domains and databases.
> However, the branding (with the exception of the header) will be the
> same for all of them as will be the functionality where plugins etc are
> concerned. I am wondering whether it is possible for the separate blogs
> to reference a central theme and plugins folder so that changes made in
> these folders are automatically propagated through all the blogs?

Check out WPMU: http://mu.wordpress.org

Other options include plugins, SVN checkouts, symlinks.

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bizarre /cache/ experience with wp_object_cache.lock

Mark Jaquith
In reply to this post by Jamie Talbot
On Feb 4, 2006, at 12:41 AM, Jamie Talbot wrote:

> Mark Jaquith wrote:
>
>> Lines 407 and 408 are redundant... we don't need to bother checking
>> safe mode if we're already disabling it by default
>
> We should still disable it for people who turn it on even though  
> they are in safe mode, shouldn't we?

Absolutely not!  As Ryan has said before, safe mode doesn't mean that  
it won't work... there exist "functional" safe mode setups.

And at any rate, that's now what those lines do.  Those lines disable  
the cache if the user is using safe mode and has not specified  
ENABLE_CACHE ... but we're already disabling the cache if the user  
hasn't specified ENABLE_CACHE, so it's pointless to have those  
lines.  The if() condition will never be true, because the lines  
before it would return before they'd even get executed.

--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
12
Loading...