mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-27 22:58:40 +02:00
Transients: Allow a non-expiring transient to be updated with an expiry.
props shahpranaf, sandyr. fixes #22807. Built from https://develop.svn.wordpress.org/trunk@27719 git-svn-id: http://core.svn.wordpress.org/trunk@27557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5a873ec0c6
commit
d63fbed03d
@ -642,9 +642,22 @@ function set_transient( $transient, $value, $expiration = 0 ) {
|
|||||||
}
|
}
|
||||||
$result = add_option( $transient, $value, '', $autoload );
|
$result = add_option( $transient, $value, '', $autoload );
|
||||||
} else {
|
} else {
|
||||||
if ( $expiration )
|
// If expiration is requested, but the transient has no timeout option,
|
||||||
update_option( $transient_timeout, time() + $expiration );
|
// delete, then re-create transient rather than update.
|
||||||
$result = update_option( $transient, $value );
|
$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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user