Make WordPress Core

Ticket #20305: 20305.diff

File 20305.diff, 3.3 KB (added by ryan, 12 years ago)
  • wp-includes/ms-blogs.php

     
    292292        foreach ( array_intersect( array_keys( $details ), $fields ) as $field )
    293293                $update_details[$field] = $details[$field];
    294294
    295         $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
     295        $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
    296296
     297        if ( false === $result )
     298                return false;
     299
    297300        // If spam status changed, issue actions.
    298301        if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {
    299302                if ( $details[ 'spam' ] == 1 )
    300                         do_action( "make_spam_blog", $blog_id );
     303                        do_action( 'make_spam_blog', $blog_id );
    301304                else
    302                         do_action( "make_ham_blog", $blog_id );
     305                        do_action( 'make_ham_blog', $blog_id );
    303306        }
    304307
    305         if ( isset($details[ 'public' ]) ) {
     308        // If mature status changed, issue actions.
     309        if ( $details[ 'mature' ] != $current_details[ 'mature' ] ) {
     310                if ( $details[ 'mature' ] == 1 )
     311                        do_action( 'mature_blog', $blog_id );
     312                else
     313                        do_action( 'unmature_blog', $blog_id );
     314        }
     315
     316        // If archived status changed, issue actions.
     317        if ( $details[ 'archived' ] != $current_details[ 'archived' ] ) {
     318                if ( $details[ 'archived' ] == 1 )
     319                        do_action( 'archive_blog', $blog_id );
     320                else
     321                        do_action( 'unarchive_blog', $blog_id );
     322        }
     323
     324        // If deleted status changed, issue actions.
     325        if ( $details[ 'deleted' ] != $current_details[ 'deleted' ] ) {
     326                if ( $details[ 'deleted' ] == 1 )
     327                        do_action( 'make_delete_blog', $blog_id );
     328                else
     329                        do_action( 'make_undelete_blog', $blog_id );
     330        }       
     331       
     332        if ( isset( $details[ 'public' ] ) ) {
    306333                switch_to_blog( $blog_id );
    307334                update_option( 'blog_public', $details[ 'public' ] );
    308335                restore_current_blog();
     
    642669        if ( null !== $deprecated  )
    643670                _deprecated_argument( __FUNCTION__, '3.1' );
    644671
    645         if ( !in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
     672        if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
    646673                return $value;
    647674
    648         $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
     675        $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
    649676
    650         refresh_blog_details($blog_id);
     677        if ( false === $result )
     678                return false;
    651679
     680        refresh_blog_details( $blog_id );
     681
    652682        if ( 'spam' == $pref )
    653683                ( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) :     do_action( 'make_ham_blog', $blog_id );
    654684        elseif ( 'mature' == $pref )
    655685                ( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id );
    656686        elseif ( 'archived' == $pref )
    657687                ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
    658         elseif ( 'archived' == $pref )
    659                 ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
     688        elseif ( 'deleted' == $pref )
     689                ( $value == 1 ) ? do_action( 'make_delete_blog', $blog_id ) : do_action( 'make_undelete_blog', $blog_id );
    660690
    661691        return $value;
    662692}