Make WordPress Core


Ignore:
Timestamp:
03/08/2014 03:15:06 AM (12 years ago)
Author:
nacin
Message:

Normalize $reassign in wp_delete_user() to ensure the hooks receive consistent values.

fixes #23057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/user.php

    r27463 r27466  
    269269 * @return bool True when finished.
    270270 */
    271 function wp_delete_user( $id, $reassign = 'novalue' ) {
     271function wp_delete_user( $id, $reassign = null ) {
    272272        global $wpdb;
    273273
     
    278278                return false;
    279279
     280        // Normalize $reassign to null or a user ID. 'novalue' was an older default.
     281        if ( 'novalue' === $reassign ) {
     282                $reassign = null;
     283        } elseif ( null !== $reassign ) {
     284                $reassign = (int) $reassign;
     285        }
     286
     287        var_dump( $reassign );
     288        die;
     289
    280290        /**
    281291         * Fires immediately before a user is deleted from the database.
     
    283293         * @since 2.0.0
    284294         *
    285          * @param int        $id       ID of the user to delete.
    286          * @param int|string $reassign ID of the user to reassign posts and links to. Default 'novalue'.
     295         * @param int      $id       ID of the user to delete.
     296         * @param int|null $reassign ID of the user to reassign posts and links to.
     297         *                           Default null, for no reassignment.
    287298         */
    288299        do_action( 'delete_user', $id, $reassign );
    289300
    290         if ( 'novalue' === $reassign || null === $reassign ) {
     301        if ( null === $reassign ) {
    291302                $post_types_to_delete = array();
    292303                foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
     
    322333                }
    323334        } else {
    324                 $reassign = (int) $reassign;
    325335                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
    326336                $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) );
     
    355365         * @since 2.9.0
    356366         *
    357          * @param int        $id       ID of the deleted user.
    358          * @param int|string $reassign ID of the user to reassign posts and links to. Default 'novalue'.
     367         * @param int      $id       ID of the deleted user.
     368         * @param int|null $reassign ID of the user to reassign posts and links to.
     369         *                           Default null, for no reassignment.
    359370         */
    360371        do_action( 'deleted_user', $id, $reassign );
Note: See TracChangeset for help on using the changeset viewer.