WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#4179 closed defect (bug) (invalid)

wp object cache ignores custom expire time

Reported by: DD32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.2
Component: Administration Keywords: has-patch, cache, object cache
Focuses: Cc:

Description

The current implementation of the WordPress object cache ignores the passed $expire value, And instead every object defaults to the hard-coded value of 900 seconds, unless defined otherwise.

Suggested Solution:

Set the modification date on the cache files to the time in the future when we want the object to expire.

Implementation:

I have included a patch to allow this to happen, any Cache calls which do not specify an expirary time are given the default expire time still, and there seem no problems setting file modification timestamps to the future.

Also in this patch i cleaned up the formatting, Changed any remaining '/' to DIRECTORY_SEPARATOR to keep in line with the rest of the file. (DIRECTORY_SEPARATOR was added in PHP 4.3.0, I assume thats WP's baseline as it was allready in use in the file). Should also fix any remaining issues with Windows not liking the Unix directory structure marker.

Also fixed a </P> nesting error in class->stats()

Attachments (2)

4179.cache.expire.patch (3.4 KB) - added by DD32 11 years ago.
cache expire patch
4179.cache.expire.2.patch (3.7 KB) - added by DD32 11 years ago.

Download all attachments as: .zip

Change History (8)

#1 @DD32
11 years ago

  • Cc DD32 added; dd32 removed

@DD32
11 years ago

cache expire patch

#2 @DD32
11 years ago

changed the diff, Uses explode() now instead of split(), should be faster, and split was causing a Regex error under Windows with '\' in the pattern.

#3 @technosailor
11 years ago

Unfortunately, PHP's baseline for WP is PHP 4.2. As for DIRECTORY_SEPARATOR - I'm pretty sure it's been around for a long time. You might be thinking of PATH_SEPARATOR which was added in PHP 4.3...

#4 @DD32
11 years ago

Hmm, It seems your right. I'll note here that wp-settings still sets a minimum of PHP 4.1

Going off a comment (just below the section in this next diff), just using / on windows can cause some issues, So as a fix, If DIRECTORY_SEPARATOR not defined, Then define it to the correct seperator depending on OS.

It could do with a test from those with < PHP 4.3

#5 @markjaquith
10 years ago

  • Milestone changed from 2.3 to 2.5

#6 @DD32
10 years ago

  • Cc DD32 removed
  • Milestone 2.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed

File-based Object cache has been removed from WordPress

Note: See TracTickets for help on using tickets.