mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Transients: Allow a non-expiring transient to be updated with an expiry.
props shahpranaf, sandyr. fixes #22807. git-svn-id: https://develop.svn.wordpress.org/trunk@27719 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -642,9 +642,22 @@ function set_transient( $transient, $value, $expiration = 0 ) {
|
||||
}
|
||||
$result = add_option( $transient, $value, '', $autoload );
|
||||
} else {
|
||||
if ( $expiration )
|
||||
update_option( $transient_timeout, time() + $expiration );
|
||||
$result = update_option( $transient, $value );
|
||||
// If expiration is requested, but the transient has no timeout option,
|
||||
// delete, then re-create transient rather than update.
|
||||
$update = true;
|
||||
if ( $expiration ) {
|
||||
if ( false === get_option( $transient_timeout ) ) {
|
||||
delete_option( $transient );
|
||||
add_option( $transient_timeout, time() + $expiration, '', 'no' );
|
||||
$result = add_option( $transient, $value, '', 'no' );
|
||||
$update = false;
|
||||
} else {
|
||||
update_option( $transient_timeout, time() + $expiration );
|
||||
}
|
||||
}
|
||||
if ( $update ) {
|
||||
$result = update_option( $transient, $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user