Make WordPress Core

Changeset 32621


Ignore:
Timestamp:
05/27/2015 06:37:29 PM (9 years ago)
Author:
wonderboymusic
Message:

Add missing doc blocks to revision.php.
Clarify @return values where necessary.
In wp_delete_post_revision(), wp_delete_post() doesn't return WP_Error, so that check can be removed.
wp_revisions_to_keep() always returns an int, so wp_revisions_enabled() can use strict comparison.

See #32444.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r32619 r32621  
    26092609
    26102610    if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
    2611             return wp_trash_post($postid);
     2611        return wp_trash_post( $postid );
    26122612
    26132613    if ( $post->post_type == 'attachment' )
  • trunk/src/wp-includes/revision.php

    r32477 r32621  
    1717 * @access private
    1818 *
    19  * @param array $post Optional a post array to be processed for insertion as a post revision.
    20  * @param bool $autosave optional Is the revision an autosave?
     19 * @staticvar array|false $fields
     20 *
     21 * @param array $post     Optional. A post array to be processed for insertion as a post revision.
     22 * @param bool  $autosave Optional. Is the revision an autosave?
    2123 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
    2224 */
     
    7880 * @since 2.6.0
    7981 *
    80  * @param  int $post_id The ID of the post to save as a revision.
    81  * @return null|int Null or 0 if error, new revision ID, if success.
     82 * @param int $post_id The ID of the post to save as a revision.
     83 * @return int|WP_Error|void Void or 0 if error, new revision ID, if success.
    8284 */
    8385function wp_save_post_revision( $post_id ) {
     
    193195 *
    194196 * @param int $post_id The post ID.
    195  * @param int $user_id optional The post author ID.
    196  * @return object|bool The autosaved data or false on failure or when no autosave exists.
     197 * @param int $user_id Optional The post author ID.
     198 * @return WP_Post|false The autosaved data or false on failure or when no autosave exists.
    197199 */
    198200function wp_get_post_autosave( $post_id, $user_id = 0 ) {
     
    216218 * @since 2.6.0
    217219 *
    218  * @param int|object $post Post ID or post object.
    219  * @return bool|int False if not a revision, ID of revision's parent otherwise.
     220 * @param int|WP_Post $post Post ID or post object.
     221 * @return false|int False if not a revision, ID of revision's parent otherwise.
    220222 */
    221223function wp_is_post_revision( $post ) {
     
    231233 * @since 2.6.0
    232234 *
    233  * @param int|object $post Post ID or post object.
    234  * @return bool|int False if not a revision, ID of autosave's parent otherwise
     235 * @param int|WP_Post $post Post ID or post object.
     236 * @return false|int False if not a revision, ID of autosave's parent otherwise
    235237 */
    236238function wp_is_post_autosave( $post ) {
     
    250252 * @access private
    251253 *
    252  * @param int|object|array $post Post ID, post object OR post array.
    253  * @param bool $autosave Optional. Is the revision an autosave?
    254  * @return mixed WP_Error or 0 if error, new revision ID if success.
     254 * @param int|WP_Post|array|null $post    Post ID, post object OR post array.
     255 * @param bool                   $autosave Optional. Is the revision an autosave?
     256 * @return int|WP_Error WP_Error or 0 if error, new revision ID if success.
    255257 */
    256258function _wp_put_post_revision( $post = null, $autosave = false ) {
     
    292294 * @since 2.6.0
    293295 *
    294  * @param int|object $post The post ID or object.
    295  * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N.
    296  * @param string $filter Optional sanitation filter. @see sanitize_post().
    297  * @return mixed Null if error or post object if success.
     296 * @param int|WP_Post $post  The post ID or object.
     297 * @param string      $output Optional. OBJECT, ARRAY_A, or ARRAY_N.
     298 * @param string      $filter Optional sanitation filter. @see sanitize_post().
     299 * @return WP_Post|array|null Null if error or post object if success.
    298300 */
    299301function wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {
     
    323325 * @since 2.6.0
    324326 *
    325  * @param int|object $revision_id Revision ID or revision object.
    326  * @param array $fields Optional. What fields to restore from. Defaults to all.
    327  * @return mixed Null if error, false if no fields to restore, (int) post ID if success.
     327 * @param int|WP_Post $revision_id Revision ID or revision object.
     328 * @param array       $fields      Optional. What fields to restore from. Defaults to all.
     329 * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success.
    328330 */
    329331function wp_restore_post_revision( $revision_id, $fields = null ) {
     
    381383 * @since 2.6.0
    382384 *
    383  * @param int|object $revision_id Revision ID or revision object.
    384  * @return mixed Null or WP_Error if error, deleted post if success.
     385 * @param int|WP_Post $revision_id Revision ID or revision object.
     386 * @return array|false|WP_Post|WP_Error|null Null or WP_Error if error, deleted post if success.
    385387 */
    386388function wp_delete_post_revision( $revision_id ) {
    387     if ( !$revision = wp_get_post_revision( $revision_id ) )
     389    if ( ! $revision = wp_get_post_revision( $revision_id ) ) {
    388390        return $revision;
     391    }
    389392
    390393    $delete = wp_delete_post( $revision->ID );
    391     if ( is_wp_error( $delete ) )
    392         return $delete;
    393 
    394394    if ( $delete ) {
    395395        /**
     
    443443 */
    444444function wp_revisions_enabled( $post ) {
    445     return wp_revisions_to_keep( $post ) != 0;
     445    return wp_revisions_to_keep( $post ) !== 0;
    446446}
    447447
     
    488488 * @since 2.7.0
    489489 * @access private
    490  */
    491 function _set_preview($post) {
    492 
    493     if ( ! is_object($post) )
     490 *
     491 * @param WP_Post $post
     492 * @return WP_Post|false
     493 */
     494function _set_preview( $post ) {
     495    if ( ! is_object( $post ) ) {
    494496        return $post;
    495 
    496     $preview = wp_get_post_autosave($post->ID);
    497 
    498     if ( ! is_object($preview) )
     497    }
     498
     499    $preview = wp_get_post_autosave( $post->ID );
     500    if ( ! is_object( $preview ) ) {
    499501        return $post;
    500 
    501     $preview = sanitize_post($preview);
     502    }
     503
     504    $preview = sanitize_post( $preview );
    502505
    503506    $post->post_content = $preview->post_content;
     
    517520 */
    518521function _show_post_preview() {
    519 
    520522    if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) {
    521523        $id = (int) $_GET['preview_id'];
     
    533535 * @since 3.6.0
    534536 * @access private
     537 *
     538 * @param array  $terms
     539 * @param int    $post_id
     540 * @param string $taxonomy
     541 * @return array
    535542 */
    536543function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
     
    554561 * @since 3.6.0
    555562 * @access private
    556 */
     563 *
     564 * @param WP_Post $revision
     565 * @return int|false
     566 */
    557567function _wp_get_post_revision_version( $revision ) {
    558568    if ( is_object( $revision ) )
     
    573583 * @access private
    574584 *
    575  * @param WP_Post $post Post object
    576  * @param array $revisions Current revisions of the post
     585 * @global wpdb $wpdb
     586 *
     587 * @param WP_Post $post      Post object
     588 * @param array   $revisions Current revisions of the post
    577589 * @return bool true if the revisions were upgraded, false if problems
    578590 */
Note: See TracChangeset for help on using the changeset viewer.