Make WordPress Core


Ignore:
Timestamp:
09/09/2023 09:26:01 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use pre-increment/decrement for stand-alone statements.

Note: This is enforced by WPCS 3.0.0:

  1. There should be no space between an increment/decrement operator and the variable it applies to.
  2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:

Props jrf.
See #59161, #58831.

File:
1 edited

Legend:

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

    r56548 r56549  
    50745074                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    50755075                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) );
    5076                 $suffix++;
     5076                ++$suffix;
    50775077            } while ( $post_name_check );
    50785078            $slug = $alt_post_name;
     
    51115111                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    51125112                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) );
    5113                 $suffix++;
     5113                ++$suffix;
    51145114            } while ( $post_name_check );
    51155115            $slug = $alt_post_name;
     
    51675167                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    51685168                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) );
    5169                 $suffix++;
     5169                ++$suffix;
    51705170            } while ( $post_name_check );
    51715171            $slug = $alt_post_name;
     
    57595759             */
    57605760            while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
    5761                 $count++;
     5761                ++$count;
    57625762                $parent = $pages[ $p->post_parent ];
    57635763                if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
Note: See TracChangeset for help on using the changeset viewer.