Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db.php

    r46586 r47122  
    8787        global $wpdb;
    8888
    89         // Save the current locale settings
     89        // Save the current locale settings.
    9090        $current_locales = explode( ';', setlocale( LC_ALL, 0 ) );
    9191
    92         // Switch to Russian
     92        // Switch to Russian.
    9393        $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES', 'ja_JP.utf8', 'ja_JP' );
    9494        if ( false === $flag ) {
     
    9696        }
    9797
    98         // Try an update query
     98        // Try an update query.
    9999        $wpdb->suppress_errors( true );
    100100        $wpdb->update(
     
    107107        $wpdb->suppress_errors( false );
    108108
    109         // Ensure the float isn't 0,700
     109        // Ensure the float isn't 0,700.
    110110        $this->assertContains( '0.700', array_pop( $this->_queries ) );
    111111
    112         // Try a prepare
     112        // Try a prepare.
    113113        $sql = $wpdb->prepare( 'UPDATE test_table SET float_column = %f AND meta_id = %d', 0.7, 5 );
    114114        $this->assertContains( '0.700', $sql );
    115115
    116         // Restore locale settings
     116        // Restore locale settings.
    117117        foreach ( $current_locales as $locale_setting ) {
    118118            if ( false !== strpos( $locale_setting, '=' ) ) {
     
    134134
    135135        $inputs   = array(
    136             'howdy%', //Single Percent
    137             'howdy_', //Single Underscore
    138             'howdy\\', //Single slash
    139             'howdy\\howdy%howdy_', //The works
    140             'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', //Plain text
     136            'howdy%',              // Single percent.
     137            'howdy_',              // Single underscore.
     138            'howdy\\',             // Single slash.
     139            'howdy\\howdy%howdy_', // The works.
     140            'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', // Plain text.
    141141        );
    142142        $expected = array(
     
    195195            array(
    196196                'a\\%aa', // SELECT 'a\\%aa'
    197                 'a\\%aa', // LIKE 'a\\\\\\%aa' # The PHP literal would be "LIKE 'a\\\\\\\\\\\\%aa'".  This is why we need reliable escape functions!
     197                'a\\%aa', // LIKE 'a\\\\\\%aa' # The PHP literal would be "LIKE 'a\\\\\\\\\\\\%aa'". This is why we need reliable escape functions!
    198198                '1',
    199199            ),
     
    235235        $dbh = $wpdb->dbh;
    236236        $this->assertNotEmpty( $dbh );
    237         $this->assertTrue( isset( $wpdb->dbh ) ); // Test __isset()
     237        $this->assertTrue( isset( $wpdb->dbh ) ); // Test __isset().
    238238        unset( $wpdb->dbh );
    239239        $this->assertTrue( empty( $wpdb->dbh ) );
     
    433433        return array(
    434434            array(
    435                 "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s",     // Query
    436                 array( 1, 'admin', 'extra-arg' ),                                   // ::prepare() args, to be passed via call_user_func_array
    437                 "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", // Expected output
     435                "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s",     // Query.
     436                array( 1, 'admin', 'extra-arg' ),                                   // ::prepare() args, to be passed via call_user_func_array().
     437                "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", // Expected output.
    438438            ),
    439439            array(
     
    749749    /**
    750750     * @ticket 21212
     751     * @ticket 32763
    751752     */
    752753    function data_get_table_from_query() {
     
    759760
    760761        $queries = array(
    761             // Basic
     762            // Basic.
    762763            "SELECT * FROM $table",
    763764            "SELECT * FROM `$table`",
     
    796797            "DELETE `a` FROM $table a",
    797798
    798             // Extended
     799            // Extended.
    799800            "EXPLAIN SELECT * FROM $table",
    800801            "EXPLAIN EXTENDED SELECT * FROM $table",
     
    898899    function data_get_escaped_table_from_show_query() {
    899900        return array(
    900             // Equality
     901            // Equality.
    901902            array( "SHOW TABLE STATUS WHERE Name = 'test_name'", 'test_name' ),
    902903            array( 'SHOW TABLE STATUS WHERE NAME="test_name"', 'test_name' ),
     
    904905            array( "SHOW FULL TABLES WHERE Name='test_name'", 'test_name' ),
    905906
    906             // LIKE
     907            // LIKE.
    907908            array( "SHOW TABLE STATUS LIKE 'test\_prefix\_%'", 'test_prefix_' ),
    908909            array( 'SHOW TABLE STATUS LIKE "test\_prefix\_%"', 'test_prefix_' ),
     
    947948                'post_parent'  => 0,
    948949            ),
    949             array( '%d', '%s' ), // These override core field_types
     950            array( '%d', '%s' ), // These override core field_types.
    950951            array(
    951952                'post_content' => array(
     
    10021003                'nor_this'                 => 1,
    10031004            ),
    1004             array( '%d', '%s' ), // The first format is used for the third
     1005            array( '%d', '%s' ), // The first format is used for the third.
    10051006            array(
    10061007                'this_is_not_a_core_field' => array(
     
    10201021
    10211022        $vars = get_defined_vars();
    1022         // Push the variable name onto the end for assertSame $message
     1023        // Push the variable name onto the end for assertSame() $message.
    10231024        foreach ( $vars as $var_name => $var ) {
    10241025            $vars[ $var_name ][] = $var_name;
     
    13931394        return array(
    13941395            array(
    1395                 '%5s',   // SQL to prepare
    1396                 'foo',   // Value to insert in the SQL
    1397                 false,   // Whether to expect an incorrect usage error or not
    1398                 '  foo', // Expected output
     1396                '%5s',   // SQL to prepare.
     1397                'foo',   // Value to insert in the SQL.
     1398                false,   // Whether to expect an incorrect usage error or not.
     1399                '  foo', // Expected output.
    13991400            ),
    14001401            array(
     
    15871588        return array(
    15881589            array(
    1589                 '%s',                                  // String to pass through esc_url()
    1590                 ' {ESCAPE} ',                          // Query to insert the output of esc_url() into, replacing "{ESCAPE}"
    1591                 'foo',                                 // Data to send to prepare()
    1592                 true,                                  // Whether to expect an incorrect usage error or not
    1593                 " {$wpdb->placeholder_escape()}s ",    // Expected output
     1590                '%s',                                  // String to pass through esc_url().
     1591                ' {ESCAPE} ',                          // Query to insert the output of esc_url() into, replacing "{ESCAPE}".
     1592                'foo',                                 // Data to send to prepare().
     1593                true,                                  // Whether to expect an incorrect usage error or not.
     1594                " {$wpdb->placeholder_escape()}s ",    // Expected output.
    15941595            ),
    15951596            array(
     
    17051706        return array(
    17061707            array(
    1707                 '',    // DB_HOST
    1708                 false, // Expect parse_db_host to bail for this hostname
    1709                 '',    // Parsed host
    1710                 null,  // Parsed port
    1711                 null,  // Parsed socket
    1712                 false, // is_ipv6
     1708                '',    // DB_HOST.
     1709                false, // Expect parse_db_host to bail for this hostname.
     1710                '',    // Parsed host.
     1711                null,  // Parsed port.
     1712                null,  // Parsed socket.
     1713                false, // $is_ipv6.
    17131714            ),
    17141715            array(
Note: See TracChangeset for help on using the changeset viewer.