Make WordPress Core

Ticket #22807: option.2.diff

File option.2.diff, 927 bytes (added by sandyr, 12 years ago)

The correct diff which passes the current unit tests

  • src/wp-includes/option.php

     
    481481                        }
    482482                        $result = add_option( $transient, $value, '', $autoload );
    483483                } else {
    484                         if ( $expiration )
    485                                 update_option( $transient_timeout, time() + $expiration );
    486                         $result = update_option( $transient, $value );
     484                        $skipupdate = false;
     485                        if ( $expiration ) {
     486                                if (false === get_option($transient_timeout)) {
     487                                        delete_option($transient);
     488                                        add_option( $transient_timeout, time() + $expiration, '', 'no' );
     489                                        $result = add_option( $transient, $value, '', 'no' );
     490                                        $skipupdate = true;
     491                                } else
     492                                        update_option( $transient_timeout, time() + $expiration );
     493                        }
     494                        if (false === $skipupdate)
     495                                $result = update_option( $transient, $value );
    487496                }
    488497        }
    489498        if ( $result ) {