From ae60693befcb124656c68074a3904f208e0be910 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 13 Nov 2022 14:49:16 +0100 Subject: [PATCH 01/36] Docs: Document the usage of globals in some functions. This affects: * `the_block_editor_meta_boxes()` * `wp_generate_block_templates_export_file()` * `WP_oEmbed_Controller::get_proxy_item()` Follow-up to [44131], [48135], [51151], [53129]. Props krunal265. Fixes #57082. git-svn-id: https://develop.svn.wordpress.org/trunk@54831 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-oembed-controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-oembed-controller.php b/src/wp-includes/class-wp-oembed-controller.php index 22fceb54..a36fff98 100755 --- a/src/wp-includes/class-wp-oembed-controller.php +++ b/src/wp-includes/class-wp-oembed-controller.php @@ -160,13 +160,14 @@ public function get_proxy_item_permissions_check() { * @since 4.8.0 * * @see WP_oEmbed::get_html() - * @global WP_Embed $wp_embed + * @global WP_Embed $wp_embed + * @global WP_Scripts $wp_scripts * * @param WP_REST_Request $request Full data about the request. * @return object|WP_Error oEmbed response data or WP_Error on failure. */ public function get_proxy_item( $request ) { - global $wp_embed; + global $wp_embed, $wp_scripts; $args = $request->get_params(); @@ -204,7 +205,6 @@ public function get_proxy_item( $request ) { $html = $wp_embed->get_embed_handler_html( $args, $url ); if ( $html ) { - global $wp_scripts; // Check if any scripts were enqueued by the shortcode, and include them in the response. $enqueued_scripts = array(); From acb68bb1a1709b3ca880fb4a3552426f7f1a9db3 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sun, 13 Nov 2022 22:29:39 +0000 Subject: [PATCH 02/36] Networks and Sites: Replace "N/A" with "Not applicable" in `choose_primary_blog()` This changeset replaces "N/A" with "Not applicable" in the `choose_primary_blog()` function. It also makes the text string translatable. Props kowsar89, SergeyBiryukov, audrasjb, mukesh27. Fixes #57040. git-svn-id: https://develop.svn.wordpress.org/trunk@54832 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 741d02e9..dc6a1455 100755 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -783,7 +783,7 @@ function choose_primary_blog() { update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); } } else { - echo 'N/A'; + _e( 'Not available' ); } ?> From 17625a7d7a2c4306ddc38f59b31dd0b6f706f213 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sun, 13 Nov 2022 23:17:47 +0000 Subject: [PATCH 03/36] Docs: Various docblock fixes in Multisite administration functions. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54833 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ms.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index dc6a1455..8b98c229 100755 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -8,7 +8,7 @@ */ /** - * Determine if uploaded file exceeds space quota. + * Determines whether uploaded file exceeds space quota. * * @since 3.0.0 * @@ -53,7 +53,7 @@ function check_upload_size( $file ) { } /** - * Delete a site. + * Deletes a site. * * @since 3.0.0 * @since 5.1.0 Use wp_delete_site() internally to delete the site row from the database. @@ -130,7 +130,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { } /** - * Delete a user from the network and remove from all sites. + * Deletes a user from the network and remove from all sites. * * @since 3.0.0 * @@ -139,7 +139,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { * @global wpdb $wpdb WordPress database abstraction object. * * @param int $id The user ID. - * @return bool True if the user was deleted, otherwise false. + * @return bool True if the user was deleted, false otherwise. */ function wpmu_delete_user( $id ) { global $wpdb; @@ -213,7 +213,7 @@ function wpmu_delete_user( $id ) { } /** - * Check whether a site has used its allotted upload space. + * Checks whether a site has used its allotted upload space. * * @since MU (3.0.0) * @@ -269,12 +269,12 @@ function display_space_usage() { } /** - * Get the remaining upload space for this site. + * Gets the remaining upload space for this site. * * @since MU (3.0.0) * - * @param int $size Current max size in bytes - * @return int Max size in bytes + * @param int $size Current max size in bytes. + * @return int Max size in bytes. */ function fix_import_form_size( $size ) { if ( upload_is_user_over_quota( false ) ) { @@ -793,7 +793,7 @@ function choose_primary_blog() { } /** - * Whether or not we can edit this network from this page. + * Determines whether or not this network from this page can be edited. * * By default editing of network is restricted to the Network Admin for that `$network_id`. * This function allows for this to be overridden. @@ -801,7 +801,7 @@ function choose_primary_blog() { * @since 3.1.0 * * @param int $network_id The network ID to check. - * @return bool True if network can be edited, otherwise false. + * @return bool True if network can be edited, false otherwise. */ function can_edit_network( $network_id ) { if ( get_current_network_id() === (int) $network_id ) { @@ -822,7 +822,7 @@ function can_edit_network( $network_id ) { } /** - * Thickbox image paths for Network Admin. + * Prints thickbox image paths for Network Admin. * * @since 3.1.0 * @@ -981,7 +981,7 @@ function confirm_delete_users( $users ) { } /** - * Print JavaScript in the header on the Network Settings screen. + * Prints JavaScript in the header on the Network Settings screen. * * @since 4.1.0 */ From ffa59a371cd0a5e33fb50fb2a5a958520fad7f5a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 14 Nov 2022 11:48:18 +0000 Subject: [PATCH 04/36] Administration: Add missing escaping for a few strings used as HTML attributes. Follow-up to [47209], [50997], [51006]. Props kowsar89, riccardodicurti, audrasjb, krupalpanchal, SergeyBiryukov. Fixes #57093. git-svn-id: https://develop.svn.wordpress.org/trunk@54834 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/nav-menu.php | 2 +- src/wp-admin/nav-menus.php | 2 +- src/wp-admin/widgets-form.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index ad8b04cf..0e09d311 100755 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -524,7 +524,7 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) { -
+
    - +

      diff --git a/src/wp-admin/widgets-form.php b/src/wp-admin/widgets-form.php index df4efdba..33f052ee 100755 --- a/src/wp-admin/widgets-form.php +++ b/src/wp-admin/widgets-form.php @@ -332,7 +332,7 @@
      - + | From 0936dab2a2effa688680e9d446ca30e14ce8b7e0 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 14 Nov 2022 14:23:00 +0000 Subject: [PATCH 05/36] Docs: Typo correction in `get_registered_nav_menus()` docblock. Props nithins53. Fixes #57101. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54835 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/nav-menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 8df3cd2c..3ef281f6 100755 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -143,7 +143,7 @@ function register_nav_menu( $location, $description ) { * * @global array $_wp_registered_nav_menus * - * @return string[] Associative array of egistered navigation menu descriptions keyed + * @return string[] Associative array of registered navigation menu descriptions keyed * by their location. If none are registered, an empty array. */ function get_registered_nav_menus() { From 840d5fde3bfc517c2cd06444c6b6288add5a2fb9 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 14 Nov 2022 21:51:57 +0000 Subject: [PATCH 06/36] Help/About: Fix inconsistency in auto-updates help tabs. This changeset ensures the wording of auto-updates related help tabs is consistent with other help tabs. Props NekoJonez, SergeyBiryukov, mukesh27, audrasjb. Fixes #56921. git-svn-id: https://develop.svn.wordpress.org/trunk@54839 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/network/themes.php | 2 +- src/wp-admin/plugins.php | 2 +- src/wp-admin/themes.php | 2 +- src/wp-admin/update-core.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php index 09c15001..930f4a19 100755 --- a/src/wp-admin/network/themes.php +++ b/src/wp-admin/network/themes.php @@ -316,7 +316,7 @@ ) ); - $help_sidebar_autoupdates = '

      ' . __( 'Learn more: Auto-updates documentation' ) . '

      '; + $help_sidebar_autoupdates = '

      ' . __( 'Documentation on Auto-updates' ) . '

      '; } get_current_screen()->set_help_sidebar( diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index dd8f8679..bc7774b1 100755 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -580,7 +580,7 @@ ) ); - $help_sidebar_autoupdates = '

      ' . __( 'Learn more: Auto-updates documentation' ) . '

      '; + $help_sidebar_autoupdates = '

      ' . __( 'Documentation on Auto-updates' ) . '

      '; } get_current_screen()->set_help_sidebar( diff --git a/src/wp-admin/themes.php b/src/wp-admin/themes.php index 6dcc9092..48627064 100755 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -199,7 +199,7 @@ ) ); - $help_sidebar_autoupdates = '

      ' . __( 'Learn more: Auto-updates documentation' ) . '

      '; + $help_sidebar_autoupdates = '

      ' . __( 'Documentation on Auto-updates' ) . '

      '; } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'. get_current_screen()->set_help_sidebar( diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index 4fd65cc1..25dea0a2 100755 --- a/src/wp-admin/update-core.php +++ b/src/wp-admin/update-core.php @@ -1008,7 +1008,7 @@ function do_undismiss_core_update() { ) ); - $help_sidebar_autoupdates = '

      ' . __( 'Learn more: Auto-updates documentation' ) . '

      '; + $help_sidebar_autoupdates = '

      ' . __( 'Documentation on Auto-updates' ) . '

      '; } get_current_screen()->set_help_sidebar( From e6506036af246307121bcd567bdb507238070e29 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 14 Nov 2022 21:55:33 +0000 Subject: [PATCH 07/36] Text Changes: Improve the wording of the email sent to confirm site deletion. Props NekoJonez, SergeyBiryukov, mukesh27, audrasjb. See #56921. git-svn-id: https://develop.svn.wordpress.org/trunk@54840 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/ms-delete-site.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/ms-delete-site.php b/src/wp-admin/ms-delete-site.php index 77246a4d..be66975f 100755 --- a/src/wp-admin/ms-delete-site.php +++ b/src/wp-admin/ms-delete-site.php @@ -65,11 +65,10 @@ be asked to confirm again so only click this link if you are absolutely certain: ###URL_DELETE### -If you delete your site, please consider opening a new site here -some time in the future! (But remember your current site and username -are gone forever.) +If you delete your site, please consider opening a new site here some time in +the future! (But remember that your current site and username are gone forever.) -Thanks for using the site, +Thank you for using the site, All at ###SITENAME### ###SITEURL###" ); From 666499ef93a44bdf05f666c974957c833b079a0f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 15 Nov 2022 00:17:03 +0000 Subject: [PATCH 08/36] Docs: Correct type for the `$post` parameter of the `{$adjacent}_post_link` filter. The parameter was documented as `WP_Post`, but it contains the value of `get_adjacent_post()`, which returns an empty string if there is no corresponding post, so the correct type is `WP_Post|string`. Follow-up to [11243], [16951], [28111], [32606]. Props apermo, audrasjb. Fixes #57047. git-svn-id: https://develop.svn.wordpress.org/trunk@54841 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index de9988be..533a7daf 100755 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -2318,11 +2318,11 @@ function get_adjacent_post_link( $format, $link, $in_same_term = false, $exclude * @since 2.6.0 * @since 4.2.0 Added the `$adjacent` parameter. * - * @param string $output The adjacent post link. - * @param string $format Link anchor format. - * @param string $link Link permalink format. - * @param WP_Post $post The adjacent post. - * @param string $adjacent Whether the post is previous or next. + * @param string $output The adjacent post link. + * @param string $format Link anchor format. + * @param string $link Link permalink format. + * @param WP_Post|string $post The adjacent post. Empty string if no corresponding post exists. + * @param string $adjacent Whether the post is previous or next. */ return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent ); } From 4c0688964fc46a9d5ed4e88247a3251b123e9cfa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 15 Nov 2022 00:32:04 +0000 Subject: [PATCH 09/36] Docs: Minor DocBlock edits for `get_adjacent_post()` and related functions. This aims to better match the line wrapping recommendations of the documentation standards. Follow-up to [16951], [28111], [32606], [37254]. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54842 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 164 ++++++++++++++++++------------ 1 file changed, 100 insertions(+), 64 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 533a7daf..25de7c79 100755 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -1752,11 +1752,13 @@ function get_edit_user_link( $user_id = null ) { * * @since 1.5.0 * - * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. - * @return WP_Post|null|string Post object if successful. Null if global $post is not set. Empty string if no - * corresponding post exists. + * @param bool $in_same_term Optional. Whether post should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. + * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set. + * Empty string if no corresponding post exists. */ function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); @@ -1767,11 +1769,13 @@ function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxono * * @since 1.5.0 * - * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. - * @return WP_Post|null|string Post object if successful. Null if global $post is not set. Empty string if no - * corresponding post exists. + * @param bool $in_same_term Optional. Whether post should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. + * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set. + * Empty string if no corresponding post exists. */ function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); @@ -1786,12 +1790,15 @@ function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = * * @global wpdb $wpdb WordPress database abstraction object. * - * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty string. - * @param bool $previous Optional. Whether to retrieve previous post. Default true - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. - * @return WP_Post|null|string Post object if successful. Null if global $post is not set. Empty string if no - * corresponding post exists. + * @param bool $in_same_term Optional. Whether post should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty string. + * @param bool $previous Optional. Whether to retrieve previous post. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. + * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set. + * Empty string if no corresponding post exists. */ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { global $wpdb; @@ -1919,7 +1926,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo * @since 4.4.0 Added the `$taxonomy` and `$post` parameters. * * @param string $join The JOIN clause in the SQL. - * @param bool $in_same_term Whether post should be in a same taxonomy term. + * @param bool $in_same_term Whether post should be in the same taxonomy term. * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided. * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true. * @param WP_Post $post WP_Post object. @@ -1941,7 +1948,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo * @since 4.4.0 Added the `$taxonomy` and `$post` parameters. * * @param string $where The `WHERE` clause in the SQL. - * @param bool $in_same_term Whether post should be in a same taxonomy term. + * @param bool $in_same_term Whether post should be in the same taxonomy term. * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided. * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true. * @param WP_Post $post WP_Post object. @@ -2001,10 +2008,13 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo * @since 2.8.0 * * @param string $title Optional. Link title format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param bool $previous Optional. Whether to display link to previous or next post. Default true. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param bool $previous Optional. Whether to display link to previous or next post. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. * @return string|void The adjacent post relational link URL. */ function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { @@ -2065,9 +2075,11 @@ function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $ * @since 2.8.0 * * @param string $title Optional. Link title format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); @@ -2100,9 +2112,11 @@ function adjacent_posts_rel_link_wp_head() { * @see get_adjacent_post_rel_link() * * @param string $title Optional. Link title format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); @@ -2116,9 +2130,11 @@ function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded * @see get_adjacent_post_rel_link() * * @param string $title Optional. Link title format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default true. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); @@ -2128,17 +2144,18 @@ function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded * Retrieves the boundary post. * * Boundary being either the first or last post by publish date within the constraints specified - * by $in_same_term or $excluded_terms. + * by `$in_same_term` or `$excluded_terms`. * * @since 2.8.0 * - * @param bool $in_same_term Optional. Whether returned post should be in a same taxonomy term. + * @param bool $in_same_term Optional. Whether returned post should be in the same taxonomy term. * Default false. * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * Default empty. - * @param bool $start Optional. Whether to retrieve first or last post. Default true - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. - * @return null|array Array containing the boundary post object if successful, null otherwise. + * @param bool $start Optional. Whether to retrieve first or last post. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. + * @return array|null Array containing the boundary post object if successful, null otherwise. */ function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { $post = get_post(); @@ -2198,9 +2215,11 @@ function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start * * @param string $format Optional. Link anchor format. Default '« %link'. * @param string $link Optional. Link permalink format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. * @return string The link URL of the previous post in relation to the current post. */ function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { @@ -2216,9 +2235,11 @@ function get_previous_post_link( $format = '« %link', $link = '%title', $i * * @param string $format Optional. Link anchor format. Default '« %link'. * @param string $link Optional. Link permalink format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); @@ -2231,9 +2252,11 @@ function previous_post_link( $format = '« %link', $link = '%title', $in_sa * * @param string $format Optional. Link anchor format. Default '« %link'. * @param string $link Optional. Link permalink format. Default '%title'. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. * @return string The link URL of the next post in relation to the current post. */ function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { @@ -2248,10 +2271,12 @@ function get_next_post_link( $format = '%link »', $link = '%title', $in_sa * @see get_next_post_link() * * @param string $format Optional. Link anchor format. Default '« %link'. - * @param string $link Optional. Link permalink format. Default '%title' - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param string $link Optional. Link permalink format. Default '%title'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. + * Default empty. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); @@ -2266,10 +2291,13 @@ function next_post_link( $format = '%link »', $link = '%title', $in_same_t * * @param string $format Link anchor format. * @param string $link Link permalink format. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded terms IDs. Default empty. - * @param bool $previous Optional. Whether to display link to previous or next post. Default true. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded terms IDs. + * Default empty. + * @param bool $previous Optional. Whether to display link to previous or next post. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. * @return string The link URL of the previous or next post in relation to the current post. */ function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { @@ -2336,10 +2364,13 @@ function get_adjacent_post_link( $format, $link, $in_same_term = false, $exclude * * @param string $format Link anchor format. * @param string $link Link permalink format. - * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. Default false. - * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs. Default empty. - * @param bool $previous Optional. Whether to display link to previous or next post. Default true. - * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. + * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. + * Default false. + * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs. + * Default empty. + * @param bool $previous Optional. Whether to display link to previous or next post. + * Default true. + * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */ function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy ); @@ -2353,8 +2384,8 @@ function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_te * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param int $pagenum Optional. Page number. Default 1. - * @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). Defaults to true. - * Otherwise, prepares the URL with sanitize_url(). + * @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). + * If set to false, prepares the URL with sanitize_url(). Default true. * @return string The link URL for the given page number. */ function get_pagenum_link( $pagenum = 1, $escape = true ) { @@ -2683,12 +2714,17 @@ function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { * @param array $args { * Optional. Default post navigation arguments. Default empty array. * - * @type string $prev_text Anchor text to display in the previous post link. Default '%title'. - * @type string $next_text Anchor text to display in the next post link. Default '%title'. - * @type bool $in_same_term Whether link should be in a same taxonomy term. Default false. - * @type int[]|string $excluded_terms Array or comma-separated list of excluded term IDs. Default empty. + * @type string $prev_text Anchor text to display in the previous post link. + * Default '%title'. + * @type string $next_text Anchor text to display in the next post link. + * Default '%title'. + * @type bool $in_same_term Whether link should be in the same taxonomy term. + * Default false. + * @type int[]|string $excluded_terms Array or comma-separated list of excluded term IDs. + * Default empty. * @type string $taxonomy Taxonomy, if `$in_same_term` is true. Default 'category'. - * @type string $screen_reader_text Screen reader text for the nav element. Default 'Post navigation'. + * @type string $screen_reader_text Screen reader text for the nav element. + * Default 'Post navigation'. * @type string $aria_label ARIA label text for the nav element. Default 'Posts'. * @type string $class Custom class for the nav element. Default 'post-navigation'. * } From 250e226a0c948e3040ff1faf0f57ca11a64134d9 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 16 Nov 2022 13:49:41 +0000 Subject: [PATCH 10/36] Docs: Split the "main part" comment in `wp-login.php` into two lines. This aims to better match the multi-line comment format of the documentation standards. Follow-up to [6643], [52945], [53313]. Props sabernhardt, NekoJonez. Fixes #56843. git-svn-id: https://develop.svn.wordpress.org/trunk@54848 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-login.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-login.php b/src/wp-login.php index 4c9de950..f7938553 100755 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -425,7 +425,9 @@ function wp_login_viewport_meta() { } /* - * Main part: check the request and redirect or display a form based on the current action. + * Main part. + * + * Check the request and redirect or display a form based on the current action. */ $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; From 67737f5d4ce50c5c1a72f7e5012d5d5742216fb3 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 16 Nov 2022 16:41:03 +0100 Subject: [PATCH 11/36] Upgrade/Install: Remove bundled theme files from `$_old_files`. Because themes are updated independently of Core updates, any deleted files from bundled themes should not be included in the `$_old_files` list. Any file included in this list is deleted on update, which could cause problems for sites with a given theme active if the removed files were required in earlier versions of that theme and that theme is not updated at the same time. Props desrosj, costdev, SergeyBiryukov. Fixes #56936. git-svn-id: https://develop.svn.wordpress.org/trunk@54849 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/update-core.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 9aa6ba40..e8c234d7 100755 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -10,6 +10,8 @@ /** * Stores files to be deleted. * + * Bundled theme files should not be included in this list. + * * @since 2.7.0 * * @global array $_old_files @@ -592,8 +594,8 @@ function update_core( $from, $to ) { // Deactivate the REST API plugin if its version is 2.0 Beta 4 or lower. _upgrade_440_force_deactivate_incompatible_plugins(); - // Deactivate the Gutenberg plugin if its version is 11.8 or lower. - _upgrade_590_force_deactivate_incompatible_plugins(); + // Deactivate incompatible plugins. + _upgrade_core_deactivate_incompatible_plugins(); // Upgrade DB with separate request. /** This filter is documented in wp-admin/includes/update-core.php */ @@ -792,14 +794,16 @@ function _upgrade_440_force_deactivate_incompatible_plugins() { /** * @access private * @ignore - * @since 5.9.0 + * @since 5.8.0 + * @since 5.9.0 The minimum compatible version of Gutenberg is 11.9. + * @since 6.1.1 The minimum compatible version of Gutenberg is 14.1. */ -function _upgrade_590_force_deactivate_incompatible_plugins() { - if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '11.9', '<' ) ) { +function _upgrade_core_deactivate_incompatible_plugins() { + if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '14.1', '<' ) ) { $deactivated_gutenberg['gutenberg'] = array( 'plugin_name' => 'Gutenberg', 'version_deactivated' => GUTENBERG_VERSION, - 'version_compatible' => '11.9', + 'version_compatible' => '14.1', ); if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) { $deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() ); From 78dfeab227f81594c27f6c390ca21383bd48abff Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 17 Nov 2022 17:05:21 +0000 Subject: [PATCH 12/36] Docs: Update `wp_count_posts` and `wp_count_attachments` filter descriptions. This aims to match the wording generally used for other filters as per the documentation standards. Follow-up to [25554], [25578], [25579], [53456]. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54854 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index dbd4e54f..acf0edf7 100755 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -2885,7 +2885,7 @@ function wp_count_posts( $type = 'post', $perm = '' ) { wp_cache_set( $cache_key, $counts, 'counts' ); /** - * Modifies returned post counts by status for the current post type. + * Filters the post counts by status for the current post type. * * @since 3.7.0 * @@ -2937,7 +2937,7 @@ function wp_count_attachments( $mime_type = '' ) { } /** - * Modifies returned attachment counts by mime type. + * Filters the attachment counts by mime type. * * @since 3.7.0 * From 29cf882739968d95fa67b64f6ccaf94cd06f11cc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 17 Nov 2022 19:13:47 +0100 Subject: [PATCH 13/36] Docs: Update various DocBlocks and inline comments per the documentation standards. Includes minor formatting edits for consistency. Follow-up to [53/tests], [12179], [12946], [35288], [37884], [38810], [38928], [46596], [48131], [52955], [53548], [53813], [53873], [54118], [54316], [54420], [54421], [54803]. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54855 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/lib/nav-menu.js | 4 +- src/wp-includes/class-wp-list-util.php | 7 ++- src/wp-includes/compat.php | 2 +- src/wp-includes/functions.php | 11 ++-- src/wp-includes/l10n.php | 15 ++--- src/wp-includes/load.php | 4 +- src/wp-includes/post.php | 7 +-- .../rest-api/class-wp-rest-server.php | 6 +- .../class-wp-rest-posts-controller.php | 20 ++++--- .../providers/class-wp-sitemaps-posts.php | 2 +- src/wp-includes/taxonomy.php | 4 +- src/wp-includes/theme.php | 2 +- tests/phpunit/includes/utils.php | 4 +- tests/phpunit/tests/functions/sizeFormat.php | 22 ++++---- tests/phpunit/tests/functions/wpListSort.php | 4 +- tests/phpunit/tests/functions/wpListUtil.php | 15 +++-- .../phpunit/tests/functions/wpNonceField.php | 55 +++++++++---------- .../tests/functions/wpRefererField.php | 3 +- .../tests/rest-api/rest-posts-controller.php | 2 + 19 files changed, 98 insertions(+), 91 deletions(-) diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index 10b1330a..9877f782 100755 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -1557,14 +1557,14 @@ }); }); - // Show bulk action + // Show bulk action. $( document ).on( 'menu-item-added', function() { if ( ! $( '.bulk-actions' ).is( ':visible' ) ) { $( '.bulk-actions' ).show(); } } ); - // Hide bulk action + // Hide bulk action. $( document ).on( 'menu-removing-item', function( e, el ) { var menuElement = $( el ).parents( '#menu-to-edit' ); if ( menuElement.find( 'li' ).length === 1 && $( '.bulk-actions' ).is( ':visible' ) ) { diff --git a/src/wp-includes/class-wp-list-util.php b/src/wp-includes/class-wp-list-util.php index a2ccfb54..3648cd89 100755 --- a/src/wp-includes/class-wp-list-util.php +++ b/src/wp-includes/class-wp-list-util.php @@ -207,9 +207,10 @@ public function pluck( $field, $index_key = null ) { * @since 4.7.0 * * @param string|array $orderby Optional. Either the field name to order by or an array - * of multiple orderby fields as $orderby => $order. - * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby - * is a string. + * of multiple orderby fields as `$orderby => $order`. + * Default empty array. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` + * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. * @return array The sorted array. */ diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index 60e8c077..31112336 100755 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -156,7 +156,7 @@ function mb_strlen( $string, $encoding = null ) { /** * Internal compat function to mimic mb_strlen(). * - * Only understands UTF-8 and 8bit. All other character sets will be treated as 8bit. + * Only understands UTF-8 and 8bit. All other character sets will be treated as 8bit. * For `$encoding === UTF-8`, the `$str` input is expected to be a valid UTF-8 byte * sequence. The behavior of this function for invalid inputs is undefined. * diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index a38c78cc..716be809 100755 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -934,7 +934,7 @@ function do_enclose( $content, $post ) { * @since 4.4.0 * * @param string[] $post_links An array of enclosure links. - * @param int $post_ID Post ID. + * @param int $post_id Post ID. */ $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); @@ -3330,7 +3330,7 @@ function wp_get_mime_types() { * @since 3.5.0 * * @param string[] $wp_get_mime_types Mime types keyed by the file extension regex - * corresponding to those types. + * corresponding to those types. */ return apply_filters( 'mime_types', @@ -5200,9 +5200,10 @@ function wp_list_pluck( $list, $field, $index_key = null ) { * * @param array $list An array of objects or arrays to sort. * @param string|array $orderby Optional. Either the field name to order by or an array - * of multiple orderby fields as $orderby => $order. - * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby - * is a string. + * of multiple orderby fields as `$orderby => $order`. + * Default empty array. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` + * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. * @return array The sorted array. */ diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index c5148a02..40c653fd 100755 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -176,7 +176,7 @@ function determine_locale() { * *Note:* Don't use translate() directly, use __() or related functions. * * @since 2.2.0 - * @since 5.5.0 Introduced gettext-{$domain} filter. + * @since 5.5.0 Introduced `gettext-{$domain}` filter. * * @param string $text Text to translate. * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. @@ -242,7 +242,7 @@ function before_last_bar( $string ) { * *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions. * * @since 2.8.0 - * @since 5.5.0 Introduced gettext_with_context-{$domain} filter. + * @since 5.5.0 Introduced `gettext_with_context-{$domain}` filter. * * @param string $text Text to translate. * @param string $context Context information for the translators. @@ -463,7 +463,7 @@ function esc_html_x( $text, $context, $domain = 'default' ) { * printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) ); * * @since 2.8.0 - * @since 5.5.0 Introduced ngettext-{$domain} filter. + * @since 5.5.0 Introduced `ngettext-{$domain}` filter. * * @param string $single The text to be used if the number is singular. * @param string $plural The text to be used if the number is plural. @@ -521,7 +521,7 @@ function _n( $single, $plural, $number, $domain = 'default' ) { * printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) ); * * @since 2.8.0 - * @since 5.5.0 Introduced ngettext_with_context-{$domain} filter. + * @since 5.5.0 Introduced `ngettext_with_context-{$domain}` filter. * * @param string $single The text to be used if the number is singular. * @param string $plural The text to be used if the number is plural. @@ -1022,9 +1022,9 @@ function load_theme_textdomain( $domain, $path = false ) { } /** - * Loads the child themes translated strings. + * Loads the child theme's translated strings. * - * If the current locale exists as a .mo file in the child themes + * If the current locale exists as a .mo file in the child theme's * root directory, it will be included in the translated strings by the $domain. * * The .mo files must be named based on the locale exactly. @@ -1361,7 +1361,8 @@ function translate_user_role( $name, $domain = 'default' ) { * * @param string $dir A directory to search for language files. * Default WP_LANG_DIR. - * @return string[] An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names. + * @return string[] An array of language codes or an empty array if no languages are present. + * Language codes are formed by stripping the .mo extension from the language file names. */ function get_available_languages( $dir = null ) { $languages = array(); diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 3cf4b0d2..52453802 100755 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -1322,10 +1322,10 @@ function get_current_network_id() { * @access private * * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. - * @global WP_Locale $wp_locale WordPress date and time locale object. + * @global WP_Locale $wp_locale WordPress date and time locale object. */ function wp_load_translations_early() { - global $wp_locale, $wp_textdomain_registry; + global $wp_textdomain_registry, $wp_locale; static $loaded = false; if ( $loaded ) { diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index acf0edf7..4f32ff30 100755 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1375,9 +1375,8 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) * * @global array $wp_post_types List of post types. * - * @param string $post_type Post type key. Must not exceed 20 characters and may - * only contain lowercase alphanumeric characters, dashes, - * and underscores. See sanitize_key(). + * @param string $post_type Post type key. Must not exceed 20 characters and may only contain + * lowercase alphanumeric characters, dashes, and underscores. See sanitize_key(). * @param array|string $args { * Array or string of arguments for registering a post type. * @@ -4026,7 +4025,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) { $post_name = $check_name; - } else { // new post, or slug has changed. + } else { // New post, or slug has changed. $post_name = sanitize_title( $post_name ); } } diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index 1690a00e..0770c97a 100755 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -553,7 +553,7 @@ public function serve_request( $path = null ) { * Converts a response to data to send. * * @since 4.4.0 - * @since 5.4.0 The $embed parameter can now contain a list of link relations to include. + * @since 5.4.0 The `$embed` parameter can now contain a list of link relations to include. * * @param WP_REST_Response $response Response object. * @param bool|string[] $embed Whether to embed all links, a filtered list of link relations, or no links. @@ -677,7 +677,7 @@ public static function get_compact_response_links( $response ) { * Embeds the links from the data into the request. * * @since 4.4.0 - * @since 5.4.0 The $embed parameter can now contain a list of link relations to include. + * @since 5.4.0 The `$embed` parameter can now contain a list of link relations to include. * * @param array $data Data from the request. * @param bool|string[] $embed Whether to embed all links or a filtered list of link relations. @@ -759,7 +759,7 @@ protected function embed_links( $data, $embed = true ) { * data instead. * * @since 4.4.0 - * @since 6.0.0 The $embed parameter can now contain a list of link relations to include + * @since 6.0.0 The `$embed` parameter can now contain a list of link relations to include. * * @param WP_REST_Response $response Response object. * @param bool|string[] $embed Whether to embed all links, a filtered list of link relations, or no links. diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 804e8ed2..655309d5 100755 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -659,11 +659,9 @@ public function create_item( $request ) { && in_array( $prepared_post->post_status, array( 'draft', 'pending' ), true ) ) { /* - * `wp_unique_post_slug()` returns the same - * slug for 'draft' or 'pending' posts. + * `wp_unique_post_slug()` returns the same slug for 'draft' or 'pending' posts. * - * To ensure that a unique slug is generated, - * pass the post data with the 'publish' status. + * To ensure that a unique slug is generated, pass the post data with the 'publish' status. */ $prepared_post->post_name = wp_unique_post_slug( $prepared_post->post_name, @@ -862,15 +860,19 @@ public function update_item( $request ) { } /* - * `wp_unique_post_slug()` returns the same - * slug for 'draft' or 'pending' posts. + * `wp_unique_post_slug()` returns the same slug for 'draft' or 'pending' posts. * - * To ensure that a unique slug is generated, - * pass the post data with the 'publish' status. + * To ensure that a unique slug is generated, pass the post data with the 'publish' status. */ if ( ! empty( $post->post_name ) && in_array( $post_status, array( 'draft', 'pending' ), true ) ) { $post_parent = ! empty( $post->post_parent ) ? $post->post_parent : 0; - $post->post_name = wp_unique_post_slug( $post->post_name, $post->ID, 'publish', $post->post_type, $post_parent ); + $post->post_name = wp_unique_post_slug( + $post->post_name, + $post->ID, + 'publish', + $post->post_type, + $post_parent + ); } // Convert the post object to an array, otherwise wp_update_post() will expect non-escaped input. diff --git a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php index a5454787..dff85a70 100755 --- a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php +++ b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php @@ -221,7 +221,7 @@ protected function get_posts_query_args( $post_type ) { 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, - 'ignore_sticky_posts' => true, // sticky posts will still appear, but they won't be moved to the front. + 'ignore_sticky_posts' => true, // Sticky posts will still appear, but they won't be moved to the front. ), $post_type ); diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 5b709681..ac73242b 100755 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -390,8 +390,8 @@ function is_taxonomy_hierarchical( $taxonomy ) { * * @global WP_Taxonomy[] $wp_taxonomies Registered taxonomies. * - * @param string $taxonomy Taxonomy key, must not exceed 32 characters and may only contain lowercase alphanumeric - * characters, dashes, and underscores. See sanitize_key(). + * @param string $taxonomy Taxonomy key. Must not exceed 32 characters and may only contain + * lowercase alphanumeric characters, dashes, and underscores. See sanitize_key(). * @param array|string $object_type Object type or array of object types with which the taxonomy should be associated. * @param array|string $args { * Optional. Array or query string of arguments for registering a taxonomy. diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 4814aaef..940083a6 100755 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -3564,7 +3564,7 @@ function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_p remove_action( 'customize_register', array( $wp_customize, 'register_controls' ) ); $wp_customize->register_controls(); - /** This filter is documented in /wp-includes/class-wp-customize-manager.php */ + /** This filter is documented in wp-includes/class-wp-customize-manager.php */ do_action( 'customize_register', $wp_customize ); } $wp_customize->_publish_changeset_values( $changeset_post->ID ); diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php index 16b331b6..1b839878 100755 --- a/tests/phpunit/includes/utils.php +++ b/tests/phpunit/includes/utils.php @@ -459,12 +459,12 @@ function gen_tests_array( $name, $array ) { } /** - * Use to create objects by yourself + * Use to create objects by yourself. */ class MockClass extends stdClass {} /** - * Drops all tables from the WordPress database + * Drops all tables from the WordPress database. */ function drop_tables() { global $wpdb; diff --git a/tests/phpunit/tests/functions/sizeFormat.php b/tests/phpunit/tests/functions/sizeFormat.php index 1337bb39..72c383ff 100755 --- a/tests/phpunit/tests/functions/sizeFormat.php +++ b/tests/phpunit/tests/functions/sizeFormat.php @@ -14,58 +14,58 @@ class Tests_Functions_SizeFormat extends WP_UnitTestCase { public function _data_size_format() { return array( - // Invalid values + // Invalid values. array( array(), 0, false ), array( 'baba', 0, false ), array( '', 0, false ), array( '-1', 0, false ), array( -1, 0, false ), - // Bytes + // Bytes. array( 0, 0, '0 B' ), array( 1, 0, '1 B' ), array( 1023, 0, '1,023 B' ), - // Kilobytes + // Kilobytes. array( KB_IN_BYTES, 0, '1 KB' ), array( KB_IN_BYTES, 2, '1.00 KB' ), array( 2.5 * KB_IN_BYTES, 0, '3 KB' ), array( 2.5 * KB_IN_BYTES, 2, '2.50 KB' ), array( 10 * KB_IN_BYTES, 0, '10 KB' ), - // Megabytes + // Megabytes. array( (string) 1024 * KB_IN_BYTES, 2, '1.00 MB' ), array( MB_IN_BYTES, 0, '1 MB' ), array( 2.5 * MB_IN_BYTES, 0, '3 MB' ), array( 2.5 * MB_IN_BYTES, 2, '2.50 MB' ), - // Gigabytes + // Gigabytes. array( (string) 1024 * MB_IN_BYTES, 2, '1.00 GB' ), array( GB_IN_BYTES, 0, '1 GB' ), array( 2.5 * GB_IN_BYTES, 0, '3 GB' ), array( 2.5 * GB_IN_BYTES, 2, '2.50 GB' ), - // Terabytes + // Terabytes. array( (string) 1024 * GB_IN_BYTES, 2, '1.00 TB' ), array( TB_IN_BYTES, 0, '1 TB' ), array( 2.5 * TB_IN_BYTES, 0, '3 TB' ), array( 2.5 * TB_IN_BYTES, 2, '2.50 TB' ), - // Petabytes + // Petabytes. array( (string) 1024 * TB_IN_BYTES, 2, '1.00 PB' ), array( PB_IN_BYTES, 0, '1 PB' ), array( 2.5 * PB_IN_BYTES, 0, '3 PB' ), array( 2.5 * PB_IN_BYTES, 2, '2.50 PB' ), - // Exabytes + // Exabytes. array( (string) 1024 * PB_IN_BYTES, 2, '1.00 EB' ), array( EB_IN_BYTES, 0, '1 EB' ), array( 2.5 * EB_IN_BYTES, 0, '3 EB' ), array( 2.5 * EB_IN_BYTES, 2, '2.50 EB' ), - // Zettabytes + // Zettabytes. array( (string) 1024 * EB_IN_BYTES, 2, '1.00 ZB' ), array( ZB_IN_BYTES, 0, '1 ZB' ), array( 2.5 * ZB_IN_BYTES, 0, '3 ZB' ), array( 2.5 * ZB_IN_BYTES, 2, '2.50 ZB' ), - // Yottabytes + // Yottabytes. array( (string) 1024 * ZB_IN_BYTES, 2, '1.00 YB' ), array( YB_IN_BYTES, 0, '1 YB' ), array( 2.5 * YB_IN_BYTES, 0, '3 YB' ), array( 2.5 * YB_IN_BYTES, 2, '2.50 YB' ), - // Edge values + // Edge values. array( TB_IN_BYTES + ( TB_IN_BYTES / 2 ) + MB_IN_BYTES, 1, '1.5 TB' ), array( TB_IN_BYTES - MB_IN_BYTES - KB_IN_BYTES, 3, '1,023.999 GB' ), ); diff --git a/tests/phpunit/tests/functions/wpListSort.php b/tests/phpunit/tests/functions/wpListSort.php index 7159af49..e493cd23 100755 --- a/tests/phpunit/tests/functions/wpListSort.php +++ b/tests/phpunit/tests/functions/wpListSort.php @@ -12,7 +12,7 @@ class Tests_Functions_wpListSort extends WP_UnitTestCase { * @dataProvider data_test_wp_list_sort * * @param string|array $orderby Either the field name to order by or an array - * of multiple orderby fields as $orderby => $order. + * of multiple orderby fields as `$orderby => $order`. * @param string $order Either 'ASC' or 'DESC'. */ public function test_wp_list_sort( $list, $orderby, $order, $expected ) { @@ -337,7 +337,7 @@ public function data_test_wp_list_sort() { * @dataProvider data_test_wp_list_sort_preserve_keys * * @param string|array $orderby Either the field name to order by or an array - * of multiple orderby fields as $orderby => $order. + * of multiple orderby fields as `$orderby => $order`. * @param string $order Either 'ASC' or 'DESC'. */ public function test_wp_list_sort_preserve_keys( $list, $orderby, $order, $expected ) { diff --git a/tests/phpunit/tests/functions/wpListUtil.php b/tests/phpunit/tests/functions/wpListUtil.php index e27831fc..f455c949 100755 --- a/tests/phpunit/tests/functions/wpListUtil.php +++ b/tests/phpunit/tests/functions/wpListUtil.php @@ -64,7 +64,8 @@ public function test_wp_list_util_get_output() { * @param array $target_array The array to create the list from. * @param string $target_key The key to pluck. * @param array $expected The expected array. - * @param string $index_key Optional. Field from the element to use as keys for the new array. Default null. + * @param string $index_key Optional. Field from the element to use as keys for the new array. + * Default null. */ public function test_wp_list_util_pluck( $target_array, $target_key, $expected, $index_key = null ) { $util = new WP_List_Util( $target_array ); @@ -156,9 +157,11 @@ public function test_wp_list_util_sort_simple() { * * @param array $expected The expected array. * @param array $target_array The array to create a list from. - * @param array $orderby Optional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order. + * @param array $orderby Optional. Either the field name to order by or an array + * of multiple orderby fields as `$orderby => $order`. * Default empty array. - * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby is a string. Default 'ASC'. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` + * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. */ public function test_wp_list_util_sort( $expected, $target_array, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { @@ -955,9 +958,11 @@ public function data_wp_list_util_sort_object_arrays() { * * @param array $expected The expected array. * @param array $target_array The array to create a list from. - * @param array $orderby Optional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order. + * @param array $orderby Optional. Either the field name to order by or an array + * of multiple orderby fields as `$orderby => $order`. * Default empty array. - * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby is a string. Default 'ASC'. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` + * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. */ public function test_wp_list_util_sort_php_7_or_greater( $expected, $target_array, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { diff --git a/tests/phpunit/tests/functions/wpNonceField.php b/tests/phpunit/tests/functions/wpNonceField.php index ec2c6872..2596402b 100755 --- a/tests/phpunit/tests/functions/wpNonceField.php +++ b/tests/phpunit/tests/functions/wpNonceField.php @@ -14,7 +14,6 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase { * @ticket 55578 */ public function test_wp_nonce_field() { - wp_nonce_field(); $this->expectOutputRegex( '#^$#' ); } @@ -24,14 +23,13 @@ public function test_wp_nonce_field() { * * @dataProvider data_wp_nonce_field * - * @param int|string $action Action name. - * @param string $name Nonce name. - * @param bool $referer Whether to set the referer field fior validation. - * @param string $expected_reg_exp The expected regular expression. + * @param int|string $action Action name. + * @param string $name Nonce name. + * @param bool $referer Whether to set the referer field for validation. + * @param string $expected_regexp The expected regular expression. */ - public function test_wp_nonce_field_return( $action, $name, $referer, $expected_reg_exp ) { - - $this->assertMatchesRegularExpression( $expected_reg_exp, wp_nonce_field( $action, $name, $referer, false ) ); + public function test_wp_nonce_field_return( $action, $name, $referer, $expected_regexp ) { + $this->assertMatchesRegularExpression( $expected_regexp, wp_nonce_field( $action, $name, $referer, false ) ); } /** @@ -40,37 +38,36 @@ public function test_wp_nonce_field_return( $action, $name, $referer, $expected_ * @return array */ public function data_wp_nonce_field() { - return array( 'default' => array( - 'action' => - 1, - 'name' => '_wpnonce', - 'referer' => true, - 'expected_reg_exp' => '#^$#', + 'action' => -1, + 'name' => '_wpnonce', + 'referer' => true, + 'expected_regexp' => '#^$#', ), 'nonce_name' => array( - 'action' => - 1, - 'name' => 'nonce_name', - 'referer' => true, - 'expected_reg_exp' => '#^$#', + 'action' => -1, + 'name' => 'nonce_name', + 'referer' => true, + 'expected_regexp' => '#^$#', ), 'action_name' => array( - 'action' => 'action_name', - 'name' => '_wpnonce', - 'referer' => true, - 'expected_reg_exp' => '#^$#', + 'action' => 'action_name', + 'name' => '_wpnonce', + 'referer' => true, + 'expected_regexp' => '#^$#', ), 'no_referer' => array( - 'action' => - 1, - 'name' => '_wpnonce', - 'referer' => false, - 'expected_reg_exp' => '#^$#', + 'action' => -1, + 'name' => '_wpnonce', + 'referer' => false, + 'expected_regexp' => '#^$#', ), '& in name' => array( - 'action' => - 1, - 'name' => 'a&b', - 'referer' => false, - 'expected_reg_exp' => '#^$#', + 'action' => -1, + 'name' => 'a&b', + 'referer' => false, + 'expected_regexp' => '#^$#', ), ); } diff --git a/tests/phpunit/tests/functions/wpRefererField.php b/tests/phpunit/tests/functions/wpRefererField.php index 6442e7a0..ca72d078 100755 --- a/tests/phpunit/tests/functions/wpRefererField.php +++ b/tests/phpunit/tests/functions/wpRefererField.php @@ -14,8 +14,8 @@ class Tests_Functions_wpRefererField extends WP_UnitTestCase { * @ticket 55578 */ public function test_wp_referer_field() { - $_SERVER['REQUEST_URI'] = '/test/'; + wp_referer_field(); $this->expectOutputString( '' ); } @@ -24,7 +24,6 @@ public function test_wp_referer_field() { * @ticket 55578 */ public function test_wp_referer_field_return() { - $_SERVER['REQUEST_URI'] = '/test/'; $this->assertSame( '', wp_referer_field( false ) ); diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index df64b296..899b7fa8 100755 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -1529,6 +1529,7 @@ public function test_get_items_not_sticky_with_exclude_no_sticky_posts() { /** * @ticket 55592 + * * @covers WP_REST_Posts_Controller::get_items * @covers ::update_post_thumbnail_cache */ @@ -1566,6 +1567,7 @@ public function test_get_items_primes_thumbnail_cache_for_featured_media() { /** * @ticket 55593 + * * @covers WP_REST_Posts_Controller::get_items * @covers ::update_post_parent_caches */ From 742a7cd8dd1241d4a7d75f90eec9c221eaf06da7 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 16 Nov 2022 19:32:57 +0000 Subject: [PATCH 14/36] Build/Test Tools: Various minor GitHub Action improvements. This applies several types of improvements to GitHub Action workflows: - Updates to inline documentation to ensure accuracy. - Removal of repetitive or unnecessary debug logging. - Reorganization of some steps to have configuration steps towards the beginning of jobs. - Step name updates for consistency across workflows. Props desrosj, jrf. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54851 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 33 +++++----------- .github/workflows/end-to-end-tests.yml | 29 +++++--------- .github/workflows/javascript-tests.yml | 18 +++------ .github/workflows/php-compatibility.yml | 8 +--- .github/workflows/phpunit-tests.yml | 28 +++++++------ .../workflows/test-and-zip-default-themes.yml | 8 ++-- .github/workflows/test-coverage.yml | 39 +++++++------------ .github/workflows/test-npm.yml | 36 ++++++++--------- 8 files changed, 76 insertions(+), 123 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 6a249a93..6a7bcf89 100755 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -48,14 +48,15 @@ jobs: # Performs the following steps: # - Checks out the repository. # - Sets up PHP. - # - Logs debug information. # - Configures caching for PHPCS scans. - # - Installs Composer dependencies (use cache if possible). + # - Installs Composer dependencies. # - Make Composer packages available globally. - # - Logs PHP_CodeSniffer debug information. # - Runs PHPCS on the full codebase with warnings suppressed. + # - Generate a report for displaying issues as pull request annotations. # - Runs PHPCS on the `tests` directory without warnings suppressed. + # - Generate a report for displaying `test` directory issues as pull request annotations. # - Ensures version-controlled files are not modified or deleted. + phpcs: name: PHP coding standards runs-on: ubuntu-latest @@ -73,11 +74,6 @@ jobs: coverage: none tools: composer, cs2pr - - name: Log debug information - run: | - php --version - composer --version - # This date is used to ensure that the PHPCS cache is cleared at least once every week. # http://man7.org/linux/man-pages/man1/date.1.html - name: "Get last Monday's date" @@ -98,9 +94,6 @@ jobs: - name: Make Composer packages available globally run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH - - name: Log PHPCS debug information - run: phpcs -i - - name: Run PHPCS on all Core files id: phpcs-core run: phpcs -n --report-full --report-checkstyle=./.cache/phpcs-report.xml @@ -126,10 +119,9 @@ jobs: # # Performs the following steps: # - Checks out the repository. + # - Sets up Node.js. # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # - Logs updated debug information. - # _ Installs npm dependencies. + # - Installs npm dependencies. # - Run the WordPress JSHint checks. # - Ensures version-controlled files are not modified or deleted. jshint: @@ -144,14 +136,7 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 - - name: Log debug information - run: | - npm --version - node --version - git --version - svn --version - - - name: Install Node.js + - name: Set up Node.js uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 with: node-version-file: '.nvmrc' @@ -161,8 +146,10 @@ jobs: run: | npm --version node --version + git --version + svn --version - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci - name: Run JSHint diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 1d642ff4..661ec67d 100755 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -35,12 +35,11 @@ jobs: # Performs the following steps: # - Sets environment variables. # - Checks out the repository. + # - Sets up Node.js. # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # _ Installs npm dependencies. + # - Installs npm dependencies. # - Builds WordPress to run from the `build` directory. # - Starts the WordPress Docker container. - # - Logs general debug information. # - Logs the running Docker containers. # - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container). # - Install WordPress within the Docker container. @@ -61,6 +60,12 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + - name: Set up Node.js + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 + with: + node-version-file: '.nvmrc' + cache: npm + - name: Log debug information run: | npm --version @@ -68,17 +73,9 @@ jobs: curl --version git --version svn --version - php --version - php -i locale -a - - name: Install Node.js - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci - name: Build WordPress @@ -88,14 +85,6 @@ jobs: run: | npm run env:start - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - name: Log running Docker containers run: docker ps -a diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 2eeeb9a8..a64dc43c 100755 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -43,10 +43,9 @@ jobs: # # Performs the following steps: # - Checks out the repository. + # - Sets up Node.js. # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # - Logs updated debug information. - # _ Installs npm dependencies. + # - Installs npm dependencies. # - Run the WordPress QUnit tests. # - Ensures version-controlled files are not modified or deleted. test-js: @@ -59,14 +58,7 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 - - name: Log debug information - run: | - npm --version - node --version - git --version - svn --version - - - name: Install Node.js + - name: Set up Node.js uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 with: node-version-file: '.nvmrc' @@ -76,8 +68,10 @@ jobs: run: | npm --version node --version + git --version + svn --version - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci - name: Run QUnit tests diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 411da95d..22b72821 100755 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -46,10 +46,10 @@ jobs: # - Sets up PHP. # - Logs debug information. # - Configures caching for PHP compatibility scans. - # - Installs Composer dependencies (use cache if possible). + # - Installs Composer dependencies. # - Make Composer packages available globally. - # - Logs PHP_CodeSniffer debug information. # - Runs the PHP compatibility tests. + # - Generate a report for displaying issues as pull request annotations. # - Ensures version-controlled files are not modified or deleted. php-compatibility: name: Check PHP compatibility @@ -70,7 +70,6 @@ jobs: - name: Log debug information run: | - php --version composer --version # This date is used to ensure that the PHP compatibility cache is cleared at least once every week. @@ -93,9 +92,6 @@ jobs: - name: Make Composer packages available globally run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH - - name: Log PHPCS debug information - run: phpcs -i - - name: Run PHP compatibility tests id: phpcs run: phpcs --standard=phpcompat.xml.dist --report-full --report-checkstyle=./.cache/phpcs-compat-report.xml diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index c2276ca0..52b7413f 100755 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -36,22 +36,20 @@ jobs: # # Performs the following steps: # - Sets environment variables. - # - Sets up the environment variables needed for testing with memcached (if desired). - # - Installs Node.js. + # - Checks out the repository. + # - Sets up Node.js. + # - Logs general debug information about the runner. # - Installs npm dependencies # - Configures caching for Composer. # - Installs Composer dependencies. # - Logs Docker debug information (about the Docker installation within the runner). # - Starts the WordPress Docker container. - # - Logs general debug information about the runner. # - Logs the running Docker containers. - # - Logs debug information from inside the WordPress Docker container. # - Logs debug information about what's installed within the WordPress Docker containers. # - Install WordPress within the Docker container. # - Run the PHPUnit tests. # - Ensures version-controlled files are not modified or deleted. # - Checks out the WordPress Test reporter repository. - # - Reconnect the directory to the Git repository. # - Submit the test results to the WordPress.org host test results. test-php: name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} @@ -108,13 +106,21 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 - - name: Install Node.js + - name: Set up Node.js uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 with: node-version-file: '.nvmrc' cache: npm - - name: Install Dependencies + - name: General debug information + run: | + npm --version + node --version + curl --version + git --version + svn --version + + - name: Install npm dependencies run: npm ci # This date is used to ensure that the Composer cache is refreshed at least once every week. @@ -155,14 +161,6 @@ jobs: run: | npm run env:start - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - name: Log running Docker containers run: docker ps -a diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml index 9c6cb3a6..f24efb45 100755 --- a/.github/workflows/test-and-zip-default-themes.yml +++ b/.github/workflows/test-and-zip-default-themes.yml @@ -49,9 +49,9 @@ jobs: # # Performs the following steps: # - Checks out the repository. - # - Installs Node.js (only when theme has a build process) - # - Installs npm dependencies (only when theme has a build process) - # - Runs the theme build script (only when theme has a build process) + # - Sets up Node.js. + # - Installs npm dependencies. + # - Runs the theme build script. # - Ensures version-controlled files are not modified or deleted. test-build-scripts: name: Test ${{ matrix.theme }} build script @@ -77,7 +77,7 @@ jobs: with: ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} - - name: Install Node.js + - name: Set up Node.js uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 with: node-version-file: '.nvmrc' diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index f91647ba..6fc2c8da 100755 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -32,26 +32,25 @@ env: LOCAL_PHP_MEMCACHED: ${{ false }} jobs: - # Sets up WordPress for testing or development use. + # Runs the PHPUnit tests for WordPress. # # Performs the following steps: # - Sets environment variables. # - Checks out the repository. - # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests). - # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # _ Installs npm dependencies. + # - Sets up Node.js. + # - Logs general debug information about the runner. + # - Installs npm dependencies + # - Configures caching for Composer. + # - Installs Composer dependencies. # - Logs Docker debug information (about the Docker installation within the runner). # - Starts the WordPress Docker container. - # - Logs debug general information. # - Logs the running Docker containers. - # - Logs WordPress Docker container debug information. # - Logs debug information about what's installed within the WordPress Docker containers. # - Install WordPress within the Docker container. # - Run the PHPUnit tests as a single site. # - Ensures version-controlled files are not modified or deleted. # - Upload the single site code coverage report to Codecov.io. - # - Run the PHPUnit tests as a multisite. + # - Run the PHPUnit tests as a multisite installation. # - Ensures version-controlled files are not modified or deleted. # - Upload the multisite code coverage report to Codecov.io. test-coverage-report: @@ -73,6 +72,12 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + - name: Set up Node.js + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 + with: + node-version-file: '.nvmrc' + cache: npm + - name: Log debug information run: | echo "$GITHUB_REF" @@ -82,17 +87,9 @@ jobs: curl --version git --version svn --version - php --version - php -i locale -a - - name: Install Node.js - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci # This date is used to ensure that the Composer cache is refreshed at least once every week. @@ -129,14 +126,6 @@ jobs: run: | npm run env:start - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - name: Log running Docker containers run: docker ps -a diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 7f38dd77..0120ef88 100755 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -41,9 +41,9 @@ jobs: # # Performs the following steps: # - Checks out the repository. + # - Sets up Node.js. # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # _ Installs npm dependencies. + # - Installs npm dependencies. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. # - Ensures version-controlled files are not modified or deleted. @@ -64,6 +64,12 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + - name: Set up Node.js + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 + with: + node-version-file: '.nvmrc' + cache: npm + - name: Log debug information run: | npm --version @@ -72,13 +78,7 @@ jobs: git --version svn --version - - name: Install Node.js - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci - name: Build WordPress in /src @@ -106,9 +106,9 @@ jobs: # # Performs the following steps: # - Checks out the repository. + # - Sets up Node.js. # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # _ Installs npm dependencies. + # - Installs npm dependencies. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. # - Ensures version-controlled files are not modified or deleted. @@ -124,6 +124,12 @@ jobs: - name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + - name: Set up Node.js + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 + with: + node-version-file: '.nvmrc' + cache: npm + - name: Log debug information run: | npm --version @@ -132,13 +138,7 @@ jobs: git --version svn --version - - name: Install Node.js - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies + - name: Install npm Dependencies run: npm ci - name: Build WordPress in /src From c08c0ee65f6ae6dfe377b9474d050ab4db2e43ed Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 16 Nov 2022 20:55:34 +0000 Subject: [PATCH 15/36] Build/Test Tools: Add additional details why MacOS jobs are separate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds additional inline context as to why the MacOS job is separate from the Windows and Ubuntu ones in the Test npm workflow. While it is preferable to combine all of these to avoid repeated code, there is currently no way to determine the runner’s OS within the `if` workflow key. MacOS jobs use GitHub Action minutes at by a multiple of 10. Being more strict about when to run these jobs ensures minutes are not unintentionally consumed within private forks and mirrors. See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54852 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/test-npm.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 0120ef88..59b8adca 100755 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -104,6 +104,10 @@ jobs: # This is separate from the job above in order to use stricter conditions about when to run. # This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate. # + # The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is + # currently no way to determine the OS being used on a given job. + # See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. + # # Performs the following steps: # - Checks out the repository. # - Sets up Node.js. From c8ee3cb16d97de5222755f798a9bc8ed06fed8e0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 18 Nov 2022 14:50:52 +0000 Subject: [PATCH 16/36] Build/Test Tools: Improve how Composer dependencies are installed. To improve how Composer dependencies are installed and managed within GitHub Actions, the `ramsey/composer-install` third-party action is now used consistently throughout all workflows. Previously, some workflows manually ran `composer` commands while others already used `ramsey/composer-install`. The `ramsey/composer-install` action manages caching dependencies across workflow runs internally, which is something that was manually handled before this change. Props jrf, desrosj. Fixes #53841. git-svn-id: https://develop.svn.wordpress.org/trunk@54856 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 7 +-- .github/workflows/php-compatibility.yml | 6 ++- .github/workflows/phpunit-tests.yml | 63 +++++++++++-------------- .github/workflows/test-coverage.yml | 58 +++++++++++------------ 4 files changed, 63 insertions(+), 71 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 6a7bcf89..06744200 100755 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -56,7 +56,6 @@ jobs: # - Runs PHPCS on the `tests` directory without warnings suppressed. # - Generate a report for displaying `test` directory issues as pull request annotations. # - Ensures version-controlled files are not modified or deleted. - phpcs: name: PHP coding standards runs-on: ubuntu-latest @@ -72,7 +71,7 @@ jobs: with: php-version: '7.4' coverage: none - tools: composer, cs2pr + tools: cs2pr # This date is used to ensure that the PHPCS cache is cleared at least once every week. # http://man7.org/linux/man-pages/man1/date.1.html @@ -86,10 +85,12 @@ jobs: path: .cache/phpcs.json key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }} + # Since Composer dependencies are installed using `composer update` and no lock file is in version control, + # passing a custom cache suffix ensures that the cache is flushed at least once per week. - name: Install Composer dependencies uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 with: - composer-options: "--no-progress --no-ansi" + custom-cache-suffix: ${{ steps.get-date.outputs.date }} - name: Make Composer packages available globally run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 22b72821..fce29378 100755 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -66,7 +66,7 @@ jobs: with: php-version: '7.4' coverage: none - tools: composer, cs2pr + tools: cs2pr - name: Log debug information run: | @@ -84,10 +84,12 @@ jobs: path: .cache/phpcompat.json key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcompat-cache-${{ hashFiles('**/composer.json', 'phpcompat.xml.dist') }} + # Since Composer dependencies are installed using `composer update` and no lock file is in version control, + # passing a custom cache suffix ensures that the cache is flushed at least once per week. - name: Install Composer dependencies uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 with: - composer-options: "--no-progress --no-ansi" + custom-cache-suffix: ${{ steps.get-date.outputs.date }} - name: Make Composer packages available globally run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 52b7413f..92ca0766 100755 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -38,10 +38,10 @@ jobs: # - Sets environment variables. # - Checks out the repository. # - Sets up Node.js. - # - Logs general debug information about the runner. - # - Installs npm dependencies - # - Configures caching for Composer. + # - Sets up PHP. # - Installs Composer dependencies. + # - Installs npm dependencies + # - Logs general debug information about the runner. # - Logs Docker debug information (about the Docker installation within the runner). # - Starts the WordPress Docker container. # - Logs the running Docker containers. @@ -112,6 +112,29 @@ jobs: node-version-file: '.nvmrc' cache: npm + ## + # This allows Composer dependencies to be installed using a single step. + # + # Since the tests are currently run within the Docker containers where the PHP version varies, + # the same PHP version needs to be configured for the action runner machine so that the correct + # dependency versions are installed and cached. + ## + - name: Set up PHP + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2.22.0 + with: + php-version: '${{ matrix.php }}' + coverage: none + + # Since Composer dependencies are installed using `composer update` and no lock file is in version control, + # passing a custom cache suffix ensures that the cache is flushed at least once per week. + - name: Install Composer dependencies + uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 + with: + custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") + + - name: Install npm dependencies + run: npm ci + - name: General debug information run: | npm --version @@ -119,38 +142,8 @@ jobs: curl --version git --version svn --version - - - name: Install npm dependencies - run: npm ci - - # This date is used to ensure that the Composer cache is refreshed at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT - - - name: Get Composer cache directory - id: composer-cache - run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache Composer dependencies - uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 - env: - cache-name: cache-composer-dependencies - with: - path: ${{ steps.composer-cache.outputs.composer_dir }} - key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }} - - - name: Install Composer dependencies - run: | - docker-compose run --rm php composer --version - - # Install using `composer update` as there is no `composer.lock` file. - if [ ${{ env.LOCAL_PHP }} == '8.2-fpm' ]; then - docker-compose run --rm php composer update --ignore-platform-req=php+ - else - docker-compose run --rm php composer update - fi + composer --version + locale -a - name: Docker debug information run: | diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 6fc2c8da..e07a7560 100755 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -38,10 +38,10 @@ jobs: # - Sets environment variables. # - Checks out the repository. # - Sets up Node.js. - # - Logs general debug information about the runner. - # - Installs npm dependencies - # - Configures caching for Composer. + # - Sets up PHP. # - Installs Composer dependencies. + # - Installs npm dependencies + # - Logs general debug information about the runner. # - Logs Docker debug information (about the Docker installation within the runner). # - Starts the WordPress Docker container. # - Logs the running Docker containers. @@ -78,6 +78,29 @@ jobs: node-version-file: '.nvmrc' cache: npm + ## + # This allows Composer dependencies to be installed using a single step. + # + # Since the tests are currently run within the Docker containers where the PHP version varies, + # the same PHP version needs to be configured for the action runner machine so that the correct + # dependency versions are installed and cached. + ## + - name: Set up PHP + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2.22.0 + with: + php-version: '7.4' + coverage: none + + # Since Composer dependencies are installed using `composer update` and no lock file is in version control, + # passing a custom cache suffix ensures that the cache is flushed at least once per week. + - name: Install Composer dependencies + uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 + with: + custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") + + - name: Install npm Dependencies + run: npm ci + - name: Log debug information run: | echo "$GITHUB_REF" @@ -87,36 +110,9 @@ jobs: curl --version git --version svn --version + composer --version locale -a - - name: Install npm Dependencies - run: npm ci - - # This date is used to ensure that the Composer cache is refreshed at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT - - - name: Get Composer cache directory - id: composer-cache - run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache Composer dependencies - uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 - env: - cache-name: cache-composer-dependencies - with: - path: ${{ steps.composer-cache.outputs.composer_dir }} - key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }} - - - name: Install Composer dependencies - run: | - docker-compose run --rm php composer --version - - # Install using `composer update` as there is no `composer.lock` file. - docker-compose run --rm php composer update - - name: Docker debug information run: | docker -v From 071ae9fcc2f5c3ae92259987d4d434375d88819e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 18 Nov 2022 15:19:07 +0000 Subject: [PATCH 17/36] Users: Add missing escaping on the Add New User screen. While the `$type` and `$label` variables are set to values that do not currently require escaping, this may change in the future, so it is preferable to add the escaping as a defensive coding measure. Follow-up to [16294], [29030]. Props monzuralam, rudlinkon, hztyfoon, peterwilsoncc. Fixes #57133. git-svn-id: https://develop.svn.wordpress.org/trunk@54857 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/user-new.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php index 7b028754..9edd7f06 100755 --- a/src/wp-admin/user-new.php +++ b/src/wp-admin/user-new.php @@ -442,8 +442,8 @@ - - + + From 53300210abbf548ed99598f9a39b46ec3f95383e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 19 Nov 2022 15:40:11 +0000 Subject: [PATCH 18/36] Coding Standards: Fix WPCS issues in `wp-admin/install-helper.php`. This commit adds inline comments instructing PHPCS to ignore some lines for database queries. An explanation is provided with each instruction. This resolves a few WPCS warnings along the lines of: {{{ Use placeholders and $wpdb->prepare(); found interpolated variable $table_name at "DESC $table_name" }}} Follow-up to [236], [265], [5778]. Props jipmoors, costdev, jrf, SergeyBiryukov. Fixes #43761. git-svn-id: https://develop.svn.wordpress.org/trunk@54858 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/install-helper.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/install-helper.php b/src/wp-admin/install-helper.php index 733321c1..e07b3d8e 100755 --- a/src/wp-admin/install-helper.php +++ b/src/wp-admin/install-helper.php @@ -59,6 +59,7 @@ function maybe_create_table( $table_name, $create_ddl ) { } // Didn't find it, so try to create it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); // We cannot directly tell that whether this succeeded! @@ -88,6 +89,7 @@ function maybe_create_table( $table_name, $create_ddl ) { function maybe_add_column( $table_name, $column_name, $create_ddl ) { global $wpdb; + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return true; @@ -95,9 +97,11 @@ function maybe_add_column( $table_name, $column_name, $create_ddl ) { } // Didn't find it, so try to create it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); // We cannot directly tell that whether this succeeded! + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return true; @@ -123,13 +127,16 @@ function maybe_add_column( $table_name, $column_name, $create_ddl ) { function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { global $wpdb; + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { // Found it, so try to drop it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $drop_ddl ); // We cannot directly tell that whether this succeeded! + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return false; @@ -174,7 +181,9 @@ function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default_value = null, $extra = null ) { global $wpdb; - $diffs = 0; + $diffs = 0; + + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. $results = $wpdb->get_results( "DESC $table_name" ); foreach ( $results as $row ) { From fadc3e847ee8f3b276b552ee003e1bdb6060dee3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 20 Nov 2022 14:08:38 +0000 Subject: [PATCH 19/36] Docs: Fix typo and improve DocBlock formatting in `wp-admin/install-helper.php`. Follow-up to [236], [265], [8645], [30542]. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54859 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/install-helper.php | 40 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/wp-admin/install-helper.php b/src/wp-admin/install-helper.php index e07b3d8e..d9aaaba5 100755 --- a/src/wp-admin/install-helper.php +++ b/src/wp-admin/install-helper.php @@ -1,28 +1,30 @@ comments, 'comment_author', 'tinytext' ) ) { * echo "ok\n"; * } * - * $error_count = 0; - * $tablename = $wpdb->links; * // Check the column. * if ( ! check_column( $wpdb->links, 'link_description', 'varchar( 255 )' ) ) { * $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; * $q = $wpdb->query( $ddl ); * } * + * $error_count = 0; + * $tablename = $wpdb->links; + * * if ( check_column( $wpdb->links, 'link_description', 'varchar( 255 )' ) ) { * $res .= $tablename . ' - ok
      '; * } else { @@ -62,7 +64,7 @@ function maybe_create_table( $table_name, $create_ddl ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); - // We cannot directly tell that whether this succeeded! + // We cannot directly tell whether this succeeded! foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) { if ( $table === $table_name ) { return true; @@ -100,7 +102,7 @@ function maybe_add_column( $table_name, $column_name, $create_ddl ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); - // We cannot directly tell that whether this succeeded! + // We cannot directly tell whether this succeeded! // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { @@ -135,7 +137,7 @@ function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $drop_ddl ); - // We cannot directly tell that whether this succeeded! + // We cannot directly tell whether this succeeded! // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { @@ -154,16 +156,16 @@ function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { * * Uses the SQL DESC for retrieving the table info for the column. It will help * understand the parameters, if you do more research on what column information - * is returned by the SQL statement. Pass in null to skip checking that - * criteria. - * - * Column names returned from DESC table are case sensitive and are listed: - * Field - * Type - * Null - * Key - * Default - * Extra + * is returned by the SQL statement. Pass in null to skip checking that criteria. + * + * Column names returned from DESC table are case sensitive and are as listed: + * + * - Field + * - Type + * - Null + * - Key + * - Default + * - Extra * * @since 1.0.0 * From 1a26a39c65f3bb99cf91b5e67515219b2c96fd1f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Nov 2022 15:02:26 +0000 Subject: [PATCH 20/36] Tests: Move `wp_filesize()` tests to their own file. This aims to make the tests more discoverable and easier to expand. Includes splitting the `wp_filesize` and `pre_wp_filesize` filter tests into a separate test case. Follow-up to [52837], [52932], [54402]. Props pbearne, spacedmonkey, SergeyBiryukov. See #57171. git-svn-id: https://develop.svn.wordpress.org/trunk@54861 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions.php | 35 ------------- tests/phpunit/tests/functions/wpFilesize.php | 53 ++++++++++++++++++++ 2 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 tests/phpunit/tests/functions/wpFilesize.php diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index ea7488a5..7f855e11 100755 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -2065,41 +2065,6 @@ public function test_wp_get_default_extension_for_mime_type() { $this->assertFalse( wp_get_default_extension_for_mime_type( null ), 'false not returned when null as mime type supplied' ); } - /** - * @ticket 49412 - * @covers ::wp_filesize - */ - function test_wp_filesize_with_nonexistent_file() { - $file = 'nonexistent/file.jpg'; - $this->assertSame( 0, wp_filesize( $file ) ); - } - - /** - * @ticket 49412 - * @covers ::wp_filesize - */ - function test_wp_filesize() { - $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg'; - - $this->assertSame( filesize( $file ), wp_filesize( $file ) ); - - $filter = function() { - return 999; - }; - - add_filter( 'wp_filesize', $filter ); - - $this->assertSame( 999, wp_filesize( $file ) ); - - $pre_filter = function() { - return 111; - }; - - add_filter( 'pre_wp_filesize', $pre_filter ); - - $this->assertSame( 111, wp_filesize( $file ) ); - } - /** * @ticket 55505 * @covers ::wp_recursive_ksort diff --git a/tests/phpunit/tests/functions/wpFilesize.php b/tests/phpunit/tests/functions/wpFilesize.php new file mode 100644 index 00000000..f65aa908 --- /dev/null +++ b/tests/phpunit/tests/functions/wpFilesize.php @@ -0,0 +1,53 @@ +assertSame( filesize( $file ), wp_filesize( $file ) ); + } + + /** + * @ticket 49412 + */ + function test_wp_filesize_filters() { + $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg'; + + add_filter( + 'wp_filesize', + static function() { + return 999; + } + ); + + $this->assertSame( 999, wp_filesize( $file ) ); + + add_filter( + 'pre_wp_filesize', + static function() { + return 111; + } + ); + + $this->assertSame( 111, wp_filesize( $file ) ); + } + + /** + * @ticket 49412 + */ + function test_wp_filesize_with_nonexistent_file() { + $file = 'nonexistent/file.jpg'; + + $this->assertSame( 0, wp_filesize( $file ) ); + } +} From d9ec815badfcc618dae7b5aea2600f5ecf02f8e9 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Nov 2022 15:09:33 +0000 Subject: [PATCH 21/36] Tests: Add a `public` visibility to `wp_filesize()` tests. Follow-up to [52010], [52837], [52932], [54861]. See #57171. git-svn-id: https://develop.svn.wordpress.org/trunk@54862 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/wpFilesize.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/functions/wpFilesize.php b/tests/phpunit/tests/functions/wpFilesize.php index f65aa908..f0e510dd 100644 --- a/tests/phpunit/tests/functions/wpFilesize.php +++ b/tests/phpunit/tests/functions/wpFilesize.php @@ -11,7 +11,7 @@ class Tests_Functions_wpFilesize extends WP_UnitTestCase { /** * @ticket 49412 */ - function test_wp_filesize() { + public function test_wp_filesize() { $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg'; $this->assertSame( filesize( $file ), wp_filesize( $file ) ); @@ -20,7 +20,7 @@ function test_wp_filesize() { /** * @ticket 49412 */ - function test_wp_filesize_filters() { + public function test_wp_filesize_filters() { $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg'; add_filter( @@ -45,7 +45,7 @@ static function() { /** * @ticket 49412 */ - function test_wp_filesize_with_nonexistent_file() { + public function test_wp_filesize_with_nonexistent_file() { $file = 'nonexistent/file.jpg'; $this->assertSame( 0, wp_filesize( $file ) ); From 05fe4eec4e564813b2201e9fe23cba04ca17bd07 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Nov 2022 19:43:25 +0000 Subject: [PATCH 22/36] =?UTF-8?q?Tests:=20Add=20unit=20tests=20for=20attac?= =?UTF-8?q?hment=E2=80=99s=20file=20size=20being=20included=20in=20metadat?= =?UTF-8?q?a.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tests ensure that `wp_generate_attachment_metadata()` stores the file size of all newly uploaded attachments under the `filesize` array key. The tests were initially supposed to be committed with [52837]. Follow-up to [52837], [52932], [54861]. Props spacedmonkey, johnwatkins0, mitogh, adamsilverstein, pbearne, SergeyBiryukov. Fixes #57171. git-svn-id: https://develop.svn.wordpress.org/trunk@54863 602fd350-edb4-49c9-b593-d223f7449a82 --- .../media/wpGenerateAttachmentMetadata.php | 89 +++++++++++++++++++ .../tests/media/wpImageTagAddDecodingAttr.php | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php diff --git a/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php b/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php new file mode 100644 index 00000000..82fe7dab --- /dev/null +++ b/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php @@ -0,0 +1,89 @@ +remove_added_uploads(); + + parent::tear_down(); + } + + /** + * Tests that filesize meta is generated for JPEGs. + * + * @ticket 49412 + * + * @covers ::wp_create_image_subsizes + */ + public function test_wp_generate_attachment_metadata_includes_filesize_in_jpg_meta() { + $attachment = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/images/canola.jpg' ); + + $metadata = wp_get_attachment_metadata( $attachment ); + + $this->assertSame( wp_filesize( get_attached_file( $attachment ) ), $metadata['filesize'] ); + + foreach ( $metadata['sizes'] as $intermediate_size ) { + $this->assertArrayHasKey( 'filesize', $intermediate_size ); + $this->assertNotEmpty( $intermediate_size['filesize'] ); + $this->assertIsNumeric( $intermediate_size['filesize'] ); + } + } + + /** + * Checks that filesize meta is generated for PNGs. + * + * @ticket 49412 + * + * @covers ::wp_create_image_subsizes + */ + public function test_wp_generate_attachment_metadata_includes_filesize_in_png_meta() { + $attachment = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.png' ); + + $metadata = wp_get_attachment_metadata( $attachment ); + + $this->assertSame( wp_filesize( get_attached_file( $attachment ) ), $metadata['filesize'] ); + } + + /** + * Checks that filesize meta is generated for PDFs. + * + * @ticket 49412 + */ + public function test_wp_generate_attachment_metadata_includes_filesize_in_pdf_meta() { + $attachment = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf' ); + + $metadata = wp_get_attachment_metadata( $attachment ); + + $this->assertSame( wp_filesize( get_attached_file( $attachment ) ), $metadata['filesize'] ); + } + + /** + * Checks that filesize meta is generated for PSDs. + * + * @ticket 49412 + */ + public function test_wp_generate_attachment_metadata_includes_filesize_in_psd_meta() { + if ( is_multisite() ) { + // PSD mime type is not allowed by default on multisite. + add_filter( + 'upload_mimes', + static function( $mimes ) { + $mimes['psd'] = 'application/octet-stream'; + return $mimes; + } + ); + } + + $attachment = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.psd' ); + + $metadata = wp_get_attachment_metadata( $attachment ); + + $this->assertSame( wp_filesize( get_attached_file( $attachment ) ), $metadata['filesize'] ); + } +} diff --git a/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php b/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php index 76fa203b..3ffe1bc6 100755 --- a/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php +++ b/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php @@ -1,7 +1,7 @@ Date: Tue, 22 Nov 2022 20:17:08 +0000 Subject: [PATCH 23/36] Tests: Clean up test file in `wpmu_delete_blog()` tests. This makes sure there are no leftover files after the tests from the `multisite` directory are run separately. Follow-up to [30404]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54864 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/multisite/msFilesRewriting.php | 2 ++ tests/phpunit/tests/multisite/site.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/phpunit/tests/multisite/msFilesRewriting.php b/tests/phpunit/tests/multisite/msFilesRewriting.php index 38818b50..7d469769 100755 --- a/tests/phpunit/tests/multisite/msFilesRewriting.php +++ b/tests/phpunit/tests/multisite/msFilesRewriting.php @@ -72,6 +72,8 @@ public function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_ // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); $this->assertFileDoesNotExist( $file2['file'] ); + + unlink( $file1['file'] ); } } diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 6507fbbf..a3e179a8 100755 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -398,6 +398,8 @@ public function test_upload_directories_after_multiple_wpmu_delete_blog() { // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); $this->assertFileDoesNotExist( $file2['file'] ); + + unlink( $file1['file'] ); } public function test_wpmu_update_blogs_date() { From 0a70f048ad3fa8895cfbe3a41af84eb07a0ea96d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Nov 2022 21:25:27 +0000 Subject: [PATCH 24/36] Tests: Correct references to `set_up()` and `tear_down()` in various DocBlocks. The `setUp()` and `tearDown()` methods were renamed to `set_up()` and `tear_down()`, respectively, as part of implementing the `void` return type solution for PHPUnit 8.0. Follow-up to [29120], [29251], [30277], [32173], [32806], [38829], [42379], [50450], [51276], [51568]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54865 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/abstract-testcase.php | 15 ++++++++------- tests/phpunit/includes/testcase-canonical.php | 4 ++-- .../tests/customize/custom-css-setting.php | 2 +- .../tests/customize/nav-menu-item-setting.php | 2 +- .../phpunit/tests/customize/nav-menu-setting.php | 2 +- tests/phpunit/tests/customize/nav-menus.php | 2 +- tests/phpunit/tests/db/dbDelta.php | 2 +- tests/phpunit/tests/query/postStatus.php | 2 +- tests/phpunit/tests/user/capabilities.php | 2 +- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 38f846e5..6cfeaa30 100755 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -322,7 +322,7 @@ protected function reset__SERVER() { * Saves the action and filter-related globals so they can be restored later. * * Stores $wp_actions, $wp_current_filter, and $wp_filter on a class variable - * so they can be restored on tearDown() using _restore_hooks(). + * so they can be restored on tear_down() using _restore_hooks(). * * @global array $wp_actions * @global array $wp_current_filter @@ -340,7 +340,7 @@ protected function _backup_hooks() { } /** - * Restores the hook-related globals to their state at setUp() + * Restores the hook-related globals to their state at set_up() * so that future tests aren't affected by hooks set during this last test. * * @global array $wp_actions @@ -1365,11 +1365,12 @@ public function rmdir( $path ) { /** * Deletes files added to the `uploads` directory during tests. * - * This method works in tandem with the `setUp()` and `rmdir()` methods: - * - `setUp()` scans the `uploads` directory before every test, and stores its contents inside of the - * `$ignore_files` property. - * - `rmdir()` and its helper methods only delete files that are not listed in the `$ignore_files` property. If - * called during `tearDown()` in tests, this will only delete files added during the previously run test. + * This method works in tandem with the `set_up()` and `rmdir()` methods: + * - `set_up()` scans the `uploads` directory before every test, and stores + * its contents inside of the `$ignore_files` property. + * - `rmdir()` and its helper methods only delete files that are not listed + * in the `$ignore_files` property. If called during `tear_down()` in tests, + * this will only delete files added during the previously run test. */ public function remove_added_uploads() { $uploads = wp_upload_dir(); diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php index 833df23e..26916fac 100755 --- a/tests/phpunit/includes/testcase-canonical.php +++ b/tests/phpunit/includes/testcase-canonical.php @@ -37,7 +37,7 @@ public function set_up() { /** * Generate fixtures to be shared between canonical tests. * - * Abstracted here because it's invoked by setUpBeforeClass() in more than one class. + * Abstracted here because it's invoked by wpSetUpBeforeClass() in more than one class. * * @since 4.1.0 */ @@ -46,7 +46,7 @@ public static function generate_shared_fixtures( WP_UnitTest_Factory $factory ) self::$author_id = $factory->user->create( array( 'user_login' => 'canonical-author' ) ); /* - * Also set in self::setUp(), but we must configure here to make sure that + * Also set in self::set_up(), but we must configure here to make sure that * post authorship is properly attributed for fixtures. */ wp_set_current_user( self::$author_id ); diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index f651b509..015b6308 100755 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -25,7 +25,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { /** * Set up the test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index 212f8717..256e5f57 100755 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -16,7 +16,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index 4a727618..6d50c96e 100755 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -17,7 +17,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 57855581..7b8ee433 100755 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -17,7 +17,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/db/dbDelta.php b/tests/phpunit/tests/db/dbDelta.php index 6667f9ab..03426fa7 100755 --- a/tests/phpunit/tests/db/dbDelta.php +++ b/tests/phpunit/tests/db/dbDelta.php @@ -99,7 +99,7 @@ public function tear_down() { parent::tear_down(); - // This has to be called after the parent `tearDown()` method. + // This has to be called after the parent `tear_down()` method. $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test" ); } diff --git a/tests/phpunit/tests/query/postStatus.php b/tests/phpunit/tests/query/postStatus.php index 1ab8aa84..238551b5 100755 --- a/tests/phpunit/tests/query/postStatus.php +++ b/tests/phpunit/tests/query/postStatus.php @@ -87,7 +87,7 @@ public function set_up() { * Register custom post types and statuses used in multiple tests. * * CPTs and CPSs are reset between each test run so need to be registered - * in both the wpSetUpBeforeClass() and setUp() methods. + * in both the wpSetUpBeforeClass() and set_up() methods. */ public static function register_custom_post_objects() { register_post_type( diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index a3b81b54..9cb46270 100755 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -1707,7 +1707,7 @@ public function test_borked_current_user_can_for_blog() { } public function nullify_current_user() { - // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog(). + // Prevents fatal errors in ::tear_down()'s and other uses of restore_current_blog(). $function_stack = wp_debug_backtrace_summary( null, 0, false ); if ( in_array( 'restore_current_blog', $function_stack, true ) ) { return; From 69dd72cd575cc01b5d11029afbe5a55fbd96b5c3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 23 Nov 2022 15:41:39 +0000 Subject: [PATCH 25/36] =?UTF-8?q?Docs:=20Revise=20comments=20using=20?= =?UTF-8?q?=E2=80=9Cwe=E2=80=9D=20in=20WordPress=20root=20directory=20file?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This updates some inline comments to better match the guidelines and recommendations set forth in the make/core and make/docs handbooks: > In general, use second person in your documentation. Second person depicts a friendly tone, with a perfect focus on the reader. In addition to this, directly addressing the reader helps avoid passive voice; thereby preventing unwanted confusion. > ... > the word “we” should be avoided (...) unless its made very clear which group is speaking. Includes: * Replacing first-person usage of "we" with second person point of view. * Making small clarification adjustments where the voice is much too casual or lacks clear context, especially for non-native English speakers. References: * [https://make.wordpress.org/docs/style-guide/language-grammar/grammatical-person/ Style Guide: Grammatical person] * [https://make.wordpress.org/docs/handbook/documentation-team-handbook/handbooks-style-and-formatting-guide/ Handbooks & HelpHub Style and Formatting Guide] * [https://make.wordpress.org/core/handbook/best-practices/post-comment-guidelines/#style-and-substance Post & Comment Guidelines: Style and Substance] Follow-up to [2176], [3430], [4676], [6009], [7991], [12688], [12762], [26008], [28978], [44488], [44962], [51979], [53131], [53132], [53156], [53131], [54200]. Props ironprogrammer, costdev, jorbin, SergeyBiryukov. See #57052. git-svn-id: https://develop.svn.wordpress.org/trunk@54866 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-cron.php | 4 ++-- src/wp-load.php | 6 +----- src/wp-login.php | 2 +- src/wp-mail.php | 2 +- src/wp-settings.php | 12 ++++++------ src/wp-trackback.php | 2 +- src/xmlrpc.php | 2 +- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/wp-cron.php b/src/wp-cron.php index 164e4ef1..f4211d82 100755 --- a/src/wp-cron.php +++ b/src/wp-cron.php @@ -23,7 +23,7 @@ header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); } -/* Don't make the request block till we finish, if possible. */ +// Don't run cron until the request finishes, if possible. if ( PHP_VERSION_ID >= 70016 && function_exists( 'fastcgi_finish_request' ) ) { fastcgi_finish_request(); } elseif ( function_exists( 'litespeed_finish_request' ) ) { @@ -35,7 +35,7 @@ } /** - * Tell WordPress we are doing the cron task. + * Tell WordPress the cron task is running. * * @var bool */ diff --git a/src/wp-load.php b/src/wp-load.php index 9e8241fe..5b869566 100755 --- a/src/wp-load.php +++ b/src/wp-load.php @@ -68,11 +68,7 @@ $path = wp_guess_url() . '/wp-admin/setup-config.php'; - /* - * We're going to redirect to setup-config.php. While this shouldn't result - * in an infinite loop, that's a silly thing to assume, don't you think? If - * we're traveling in circles, our last-ditch effort is "Need more help?" - */ + // Redirect to setup-config.php. if ( false === strpos( $_SERVER['REQUEST_URI'], 'setup-config' ) ) { header( 'Location: ' . $path ); exit; diff --git a/src/wp-login.php b/src/wp-login.php index f7938553..a6a7bc81 100755 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -1244,7 +1244,7 @@ function wp_login_viewport_meta() { ) ); } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { - // If cookies are disabled, we can't log in even with a valid user and password. + // If cookies are disabled, the user can't log in even with a valid username and password. $user = new WP_Error( 'test_cookie', sprintf( diff --git a/src/wp-mail.php b/src/wp-mail.php index eab3e0cf..b37a88b8 100755 --- a/src/wp-mail.php +++ b/src/wp-mail.php @@ -231,7 +231,7 @@ echo "\n" . $post_ID->get_error_message(); } - // We couldn't post, for whatever reason. Better move forward to the next email. + // The post wasn't inserted or updated, for whatever reason. Better move forward to the next email. if ( empty( $post_ID ) ) { continue; } diff --git a/src/wp-settings.php b/src/wp-settings.php index 19aac7f9..f5be2a74 100755 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -19,8 +19,8 @@ * Version information for the current WordPress release. * * These can't be directly globalized in version.php. When updating, - * we're including version.php from another installation and don't want - * these values to be overridden if already set. + * include version.php from another installation and don't override + * these values if already set. * * @global string $wp_version The WordPress version string. * @global int $wp_db_version WordPress database version. @@ -60,7 +60,7 @@ // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE. wp_initial_constants(); -// Make sure we register the shutdown handler for fatal errors as soon as possible. +// Register the shutdown handler for fatal errors as soon as possible. wp_register_fatal_error_handler(); // WordPress calculates offsets from UTC. @@ -70,13 +70,13 @@ // Standardize $_SERVER variables across setups. wp_fix_server_vars(); -// Check if we're in maintenance mode. +// Check if the site is in maintenance mode. wp_maintenance(); // Start loading timer. timer_start(); -// Check if we're in WP_DEBUG mode. +// Check if WP_DEBUG mode is enabled. wp_debug_mode(); /** @@ -145,7 +145,7 @@ register_shutdown_function( 'shutdown_action_hook' ); -// Stop most of WordPress from being loaded if we just want the basics. +// Stop most of WordPress from being loaded if SHORTINIT is enabled. if ( SHORTINIT ) { return false; } diff --git a/src/wp-trackback.php b/src/wp-trackback.php index d7d18814..7512e33f 100755 --- a/src/wp-trackback.php +++ b/src/wp-trackback.php @@ -76,7 +76,7 @@ function trackback_response( $error = 0, $error_message = '' ) { $blog_name = mb_convert_encoding( $blog_name, get_option( 'blog_charset' ), $charset ); } -// Now that mb_convert_encoding() has been given a swing, we need to escape these three. +// Escape values to use in the trackback. $title = wp_slash( $title ); $excerpt = wp_slash( $excerpt ); $blog_name = wp_slash( $blog_name ); diff --git a/src/xmlrpc.php b/src/xmlrpc.php index 341a6dc8..ecac4c7c 100755 --- a/src/xmlrpc.php +++ b/src/xmlrpc.php @@ -12,7 +12,7 @@ */ define( 'XMLRPC_REQUEST', true ); -// Some browser-embedded clients send cookies. We don't want them. +// Discard unneeded cookies sent by some browser-embedded clients. $_COOKIE = array(); // $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0. From a6ed73e6c07a2c1ff9f92744934c27e6849af4e5 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 23 Nov 2022 22:28:15 +0100 Subject: [PATCH 26/36] Docs: Improve various globals documentation, as per documentation standards. Props upadalavipul, mukesh27, krupalpanchal, jigar-bhanushali. See #57069, #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54867 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 2 ++ src/wp-includes/class-wp-locale.php | 1 - src/wp-includes/class-wp-tax-query.php | 2 -- src/wp-includes/class-wp-term-query.php | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index a2b2c9ed..88c6d5d6 100755 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -911,6 +911,8 @@ public function maintenance_mode( $enable = false ) { * * @since 4.5.0 * + * @global wpdb $wpdb The WordPress database abstraction object. + * * @param string $lock_name The name of this unique lock. * @param int $release_timeout Optional. The duration in seconds to respect an existing lock. * Default: 1 hour. diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php index ca98f9d3..b001a099 100755 --- a/src/wp-includes/class-wp-locale.php +++ b/src/wp-includes/class-wp-locale.php @@ -124,7 +124,6 @@ public function __construct() { * @since 2.1.0 * * @global string $text_direction - * @global string $wp_version The WordPress version string. */ public function init() { // The weekdays. diff --git a/src/wp-includes/class-wp-tax-query.php b/src/wp-includes/class-wp-tax-query.php index e7b1e2a9..881e0ce2 100755 --- a/src/wp-includes/class-wp-tax-query.php +++ b/src/wp-includes/class-wp-tax-query.php @@ -589,8 +589,6 @@ private function clean_query( &$query ) { * * @since 3.2.0 * - * @global wpdb $wpdb The WordPress database abstraction object. - * * @param array $query The single query. Passed by reference. * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id', * or 'term_id'. Default 'term_id'. diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php index 18c85e89..ae391bfc 100755 --- a/src/wp-includes/class-wp-term-query.php +++ b/src/wp-includes/class-wp-term-query.php @@ -910,8 +910,6 @@ public function get_terms() { * * @since 4.6.0 * - * @global wpdb $wpdb WordPress database abstraction object. - * * @param string $orderby_raw Alias for the field to order by. * @return string|false Value to used in the ORDER clause. False otherwise. */ From 9e9935d9bf433b77f67d2b5b785f5fa5f038f8bb Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 23 Nov 2022 21:34:24 +0000 Subject: [PATCH 27/36] Docs: Improve various globals documentation, as per documentation standards. Props upadalavipul. See #57069, #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54868 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 9cae9b93..561ed30b 100755 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -3683,6 +3683,9 @@ function wp_preload_resources() { * * @since 4.6.0 * + * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts. + * @global WP_Styles $wp_styles The WP_Styles object for printing styles. + * * @return string[] A list of unique hosts of enqueued scripts and styles. */ function wp_dependencies_unique_hosts() { From a607ee43a1875ae69fb14c946c68dabb0d33441f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 24 Nov 2022 14:16:18 +0000 Subject: [PATCH 28/36] Coding Standards: Use `HOUR_IN_SECONDS` where appropriate. This aims to clarify the time units for some time offset values. Follow-up to [21996], [23823], [40108], [41626]. See #56791. git-svn-id: https://develop.svn.wordpress.org/trunk@54870 602fd350-edb4-49c9-b593-d223f7449a82 --- .../customize/class-wp-customize-date-time-control.php | 2 +- .../rest-api/endpoints/class-wp-rest-posts-controller.php | 2 +- src/wp-includes/revision.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/customize/class-wp-customize-date-time-control.php b/src/wp-includes/customize/class-wp-customize-date-time-control.php index 55bf64db..a055b4ee 100755 --- a/src/wp-includes/customize/class-wp-customize-date-time-control.php +++ b/src/wp-includes/customize/class-wp-customize-date-time-control.php @@ -234,7 +234,7 @@ public function get_timezone_info() { if ( $tz ) { $now = new DateTime( 'now', $tz ); - $formatted_gmt_offset = $this->format_gmt_offset( $tz->getOffset( $now ) / 3600 ); + $formatted_gmt_offset = $this->format_gmt_offset( $tz->getOffset( $now ) / HOUR_IN_SECONDS ); $tz_name = str_replace( '_', ' ', $tz->getName() ); $timezone_info['abbr'] = $now->format( 'T' ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 655309d5..5cbec60f 100755 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1797,7 +1797,7 @@ public function prepare_item_for_response( $item, $request ) { * with the site's timezone offset applied. */ if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { - $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); + $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); } else { $post_modified_gmt = $post->post_modified_gmt; } diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index 0f76f908..9d3ca6f4 100755 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -859,7 +859,7 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { return false; } - if ( $locked > $now - 3600 ) { + if ( $locked > $now - HOUR_IN_SECONDS ) { // Lock is not too old: some other process may be upgrading this post. Bail. return false; } From 67a9243c86b6f19b36339d002cdc64adbd861e56 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Thu, 24 Nov 2022 15:36:42 +0000 Subject: [PATCH 29/36] Plugins: Improve "No plugin found" message alignement in Plugins screen. This changeset centers the "No plugin found" message in plugin search results. Follow-up to [54149]. Props sruthi90, aparnajl, krupalpanchal, audrasjb, anantajitjg. Fixes #57194. See #55721, #55272. git-svn-id: https://develop.svn.wordpress.org/trunk@54871 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/list-tables.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index 440d2a53..00a6d8c4 100755 --- a/src/wp-admin/css/list-tables.css +++ b/src/wp-admin/css/list-tables.css @@ -1636,6 +1636,7 @@ div.action-links, font-style: normal; margin: 0; padding: 100px 0 0; + width: 100%; text-align: center; } From c6283ffeff9e28d930df5d4e20162d0e28a2f0f5 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Thu, 24 Nov 2022 22:09:39 +0000 Subject: [PATCH 30/36] Coding Standards: Remove extra slashes when concatenating `ABSPATH` with a path. Since `ABSPATH` is defined and documented to end with a forward slash `/`, this changeset removes the first `/` from strings appended to `ABSPATH` in various files, leading to `//` in the resulting path. Props TobiasBg, audrasjb, SergeyBiryukov, emanuelx. Fixes #57074. See #57071. git-svn-id: https://develop.svn.wordpress.org/trunk@54872 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-site-health-auto-updates.php | 4 ++-- src/wp-admin/includes/class-wp-site-health.php | 2 +- src/wp-admin/includes/file.php | 2 +- tests/phpunit/includes/bootstrap.php | 2 +- tests/phpunit/includes/install.php | 6 +++--- tests/phpunit/tests/customize/widgets.php | 2 +- tests/phpunit/tests/feed/wpSimplePieFile.php | 4 ++-- tests/phpunit/tests/pluggable/signatures.php | 4 ++-- tests/phpunit/tests/pluggable/wpMail.php | 2 +- tests/phpunit/tests/pomo/po.php | 2 +- tests/phpunit/tests/post.php | 2 +- tests/phpunit/tests/widgets.php | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index f6fb7d79..e3c02d06 100755 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -277,7 +277,7 @@ public function test_vcs_abspath() { public function test_check_wp_filesystem_method() { // Make sure the `request_filesystem_credentials()` function is available during our REST API call. if ( ! function_exists( 'request_filesystem_credentials' ) ) { - require_once ABSPATH . '/wp-admin/includes/file.php'; + require_once ABSPATH . 'wp-admin/includes/file.php'; } $skin = new Automatic_Upgrader_Skin; @@ -328,7 +328,7 @@ public function test_all_files_writable() { // Make sure the `get_core_checksums()` function is available during our REST API call. if ( ! function_exists( 'get_core_checksums' ) ) { - require_once ABSPATH . '/wp-admin/includes/update.php'; + require_once ABSPATH . 'wp-admin/includes/update.php'; } $checksums = get_core_checksums( $wp_version, 'en_US' ); diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index abe0fc61..4300abd8 100755 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -65,7 +65,7 @@ public function __construct() { */ public function show_site_health_tab( $tab ) { if ( 'debug' === $tab ) { - require_once ABSPATH . '/wp-admin/site-health-info.php'; + require_once ABSPATH . 'wp-admin/site-health-info.php'; } } diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index bfd32ec8..a89e6010 100755 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -2442,7 +2442,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, // Make sure the `submit_button()` function is available during the REST API call // from WP_Site_Health_Auto_Updates::test_check_wp_filesystem_method(). if ( ! function_exists( 'submit_button' ) ) { - require_once ABSPATH . '/wp-admin/includes/template.php'; + require_once ABSPATH . 'wp-admin/includes/template.php'; } ?>

      diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index be0c0180..5610d671 100755 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -302,7 +302,7 @@ function wp_tests_options( $value ) { } // Load WordPress. -require_once ABSPATH . '/wp-settings.php'; +require_once ABSPATH . 'wp-settings.php'; // Delete any default posts & related data. _delete_all_posts(); diff --git a/tests/phpunit/includes/install.php b/tests/phpunit/includes/install.php index 1357b4d5..3157fd93 100755 --- a/tests/phpunit/includes/install.php +++ b/tests/phpunit/includes/install.php @@ -37,10 +37,10 @@ tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter_exit' ); -require_once ABSPATH . '/wp-settings.php'; +require_once ABSPATH . 'wp-settings.php'; -require_once ABSPATH . '/wp-admin/includes/upgrade.php'; -require_once ABSPATH . '/wp-includes/class-wpdb.php'; +require_once ABSPATH . 'wp-admin/includes/upgrade.php'; +require_once ABSPATH . 'wp-includes/class-wpdb.php'; // Override the PHPMailer. global $phpmailer; diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index 94630bc7..68e908ad 100755 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -470,7 +470,7 @@ public function test_sanitize_widget_instance_empty_instance() { */ private function get_test_widget_control_args() { global $wp_registered_widgets; - require_once ABSPATH . '/wp-admin/includes/widgets.php'; + require_once ABSPATH . 'wp-admin/includes/widgets.php'; $widget_id = 'search-2'; $widget = $wp_registered_widgets[ $widget_id ]; $args = array( diff --git a/tests/phpunit/tests/feed/wpSimplePieFile.php b/tests/phpunit/tests/feed/wpSimplePieFile.php index f9748e3a..fe16352c 100755 --- a/tests/phpunit/tests/feed/wpSimplePieFile.php +++ b/tests/phpunit/tests/feed/wpSimplePieFile.php @@ -19,8 +19,8 @@ class Tests_Feed_wpSimplePieFile extends WP_UnitTestCase { public static function set_up_before_class() { parent::set_up_before_class(); - require_once ABSPATH . '/wp-includes/class-simplepie.php'; - require_once ABSPATH . '/wp-includes/class-wp-simplepie-file.php'; + require_once ABSPATH . 'wp-includes/class-simplepie.php'; + require_once ABSPATH . 'wp-includes/class-wp-simplepie-file.php'; } /** diff --git a/tests/phpunit/tests/pluggable/signatures.php b/tests/phpunit/tests/pluggable/signatures.php index a802b037..71c70296 100755 --- a/tests/phpunit/tests/pluggable/signatures.php +++ b/tests/phpunit/tests/pluggable/signatures.php @@ -76,7 +76,7 @@ public function test_all_pluggable_functions_exist() { */ public function get_defined_pluggable_functions() { - require_once ABSPATH . '/wp-admin/includes/upgrade.php'; + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $test_functions = array( 'install_network', @@ -103,7 +103,7 @@ public function get_defined_pluggable_functions() { } foreach ( $test_files as $file ) { - preg_match_all( '#^\t?function (\w+)#m', file_get_contents( ABSPATH . '/' . $file ), $functions ); + preg_match_all( '#^\t?function (\w+)#m', file_get_contents( ABSPATH . $file ), $functions ); foreach ( $functions[1] as $function ) { $data[] = array( diff --git a/tests/phpunit/tests/pluggable/wpMail.php b/tests/phpunit/tests/pluggable/wpMail.php index bbe27bd8..68982d60 100755 --- a/tests/phpunit/tests/pluggable/wpMail.php +++ b/tests/phpunit/tests/pluggable/wpMail.php @@ -173,7 +173,7 @@ public function test_wp_mail_return_value() { $this->assertTrue( wp_mail( 'valid@address.com', 'subject', 'body' ) ); // Non-fatal errors. - $this->assertTrue( wp_mail( 'valid@address.com', 'subject', 'body', "Cc: invalid-address\nBcc: @invalid.address", ABSPATH . '/non-existent-file.html' ) ); + $this->assertTrue( wp_mail( 'valid@address.com', 'subject', 'body', "Cc: invalid-address\nBcc: @invalid.address", ABSPATH . 'non-existent-file.html' ) ); // Fatal errors. $this->assertFalse( wp_mail( 'invalid.address', 'subject', 'body', '', array() ) ); diff --git a/tests/phpunit/tests/pomo/po.php b/tests/phpunit/tests/pomo/po.php index d7652f27..8c58099b 100755 --- a/tests/phpunit/tests/pomo/po.php +++ b/tests/phpunit/tests/pomo/po.php @@ -48,7 +48,7 @@ class Tests_POMO_PO extends WP_UnitTestCase { public static function set_up_before_class() { parent::set_up_before_class(); - require_once ABSPATH . '/wp-includes/pomo/po.php'; + require_once ABSPATH . 'wp-includes/pomo/po.php'; } public function test_prepend_each_line() { diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 7d0a5bc0..14da9703 100755 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -285,7 +285,7 @@ public function test_utf8mb3_post_saves_with_emoji() { $this->markTestSkipped( 'This test is only useful with the utf8 character set.' ); } - require_once ABSPATH . '/wp-admin/includes/post.php'; + require_once ABSPATH . 'wp-admin/includes/post.php'; $post_id = self::factory()->post->create(); diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 440bac21..a89f7c8d 100755 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -708,7 +708,7 @@ public function test_wp_widget_control() { ); wp_widgets_init(); - require_once ABSPATH . '/wp-admin/includes/widgets.php'; + require_once ABSPATH . 'wp-admin/includes/widgets.php'; $widget_id = 'search-2'; $widget = $wp_registered_widgets[ $widget_id ]; $params = array( From 8c5a9db4eeac59722491270530e80fe1bdab671d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 25 Nov 2022 15:10:48 +0000 Subject: [PATCH 31/36] Docs: Correct the type for `_WP_Dependency::$src` property. The handle source can be set to `false`, which means the item is an alias of other items it depends on. Follow-up to [7970], [25518], [43661], [47170], [48462], [54470]. Props mehulkaklotar, swissspidy, costdev. Fixes #57206. git-svn-id: https://develop.svn.wordpress.org/trunk@54875 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-dependencies.php | 2 +- src/wp-includes/class-wp-dependency.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index 68b33be3..0bc42bb2 100755 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -241,7 +241,7 @@ public function all_deps( $handles, $recursion = false, $group = false ) { * @param string $handle Name of the item. Should be unique. * @param string|false $src Full URL of the item, or path of the item relative * to the WordPress root directory. If source is set to false, - * item is an alias of other items it depends on. + * the item is an alias of other items it depends on. * @param string[] $deps Optional. An array of registered item handles this item depends on. * Default empty array. * @param string|bool|null $ver Optional. String specifying item version number, if it has one, diff --git a/src/wp-includes/class-wp-dependency.php b/src/wp-includes/class-wp-dependency.php index a0188117..bcc78082 100755 --- a/src/wp-includes/class-wp-dependency.php +++ b/src/wp-includes/class-wp-dependency.php @@ -29,8 +29,10 @@ class _WP_Dependency { /** * The handle source. * + * If source is set to false, the item is an alias of other items it depends on. + * * @since 2.6.0 - * @var string + * @var string|false */ public $src; From 2092fd8c9f3a8791fec92fd8b7eac21257c2c853 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sat, 26 Nov 2022 09:10:28 +0000 Subject: [PATCH 32/36] Coding Standards: Fix brace indentation in `wp-align/includes/noop.php`. Props alberuni-azad. Fixes #57209. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54876 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/noop.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/noop.php b/src/wp-admin/includes/noop.php index ba611fc9..b29f6044 100755 --- a/src/wp-admin/includes/noop.php +++ b/src/wp-admin/includes/noop.php @@ -66,7 +66,8 @@ function get_bloginfo() {} * @ignore */ function is_admin() { - return true;} + return true; +} /** * @ignore From 7df6b7c35aabe9828eb8e16d90d57e9e9346f4db Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sat, 26 Nov 2022 09:37:18 +0000 Subject: [PATCH 33/36] Docs: Improve various globals documentation, as per documentation standards. Props upadalavipul. See #57069, #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54877 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-taxonomy.php | 2 -- src/wp-includes/class-wp-xmlrpc-server.php | 2 ++ src/wp-includes/comment.php | 2 ++ src/wp-includes/functions.php | 2 -- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-taxonomy.php b/src/wp-includes/class-wp-taxonomy.php index 1f7eed96..a73be9ea 100755 --- a/src/wp-includes/class-wp-taxonomy.php +++ b/src/wp-includes/class-wp-taxonomy.php @@ -278,8 +278,6 @@ final class WP_Taxonomy { * * @since 4.7.0 * - * @global WP $wp Current WordPress environment instance. - * * @param string $taxonomy Taxonomy key, must not exceed 32 characters. * @param array|string $object_type Name of the object type for the taxonomy object. * @param array|string $args Optional. Array or query string of arguments for registering a taxonomy. diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 97234880..0c574475 100755 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -6819,6 +6819,8 @@ public function mt_publishPost( $args ) { * * @since 1.5.0 * + * @global wpdb $wpdb WordPress database abstraction object. + * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index b5be18ed..ca79d54a 100755 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -3783,6 +3783,8 @@ function wp_register_comment_personal_data_eraser( $erasers ) { * * @since 4.9.6 * + * @global wpdb $wpdb WordPress database abstraction object. + * * @param string $email_address The comment author email address. * @param int $page Comment page. * @return array diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 716be809..8cb36f5e 100755 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -163,8 +163,6 @@ function wp_timezone() { * @since 0.71 * @since 5.3.0 Converted into a wrapper for wp_date(). * - * @global WP_Locale $wp_locale WordPress date and time locale object. - * * @param string $format Format to display the date. * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset * in seconds. Default false. From 86bbd2b9cb7edb1229c24c08019b85f0a4d3e978 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 26 Nov 2022 16:11:01 +0000 Subject: [PATCH 34/36] Coding Standards: Correct the deprecation version for `_filter_query_attachment_filenames()`. Follow-up to [54524]. Props jrf. See #56791. git-svn-id: https://develop.svn.wordpress.org/trunk@54878 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/deprecated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index 6273a7f2..26185a68 100755 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -4484,7 +4484,7 @@ function global_terms_enabled() { * @return array The unmodified clauses. */ function _filter_query_attachment_filenames( $clauses ) { - _deprecated_function( __FUNCTION__, '4.9.9', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )' ); + _deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )' ); remove_filter( 'posts_clauses', __FUNCTION__ ); return $clauses; } From 51c3c17a0522d8a3d0265d9a799e1484d7062647 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sat, 26 Nov 2022 20:59:05 +0000 Subject: [PATCH 35/36] Coding Standards: Various brace indentation corrections. Props mukesh27. Fixes #57210. See #56791. git-svn-id: https://develop.svn.wordpress.org/trunk@54881 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/export.php | 3 ++- src/wp-admin/includes/file.php | 3 ++- src/wp-admin/options-discussion.php | 3 ++- src/wp-admin/theme-editor.php | 3 ++- src/wp-includes/feed-atom-comments.php | 3 ++- src/wp-includes/theme-compat/header.php | 3 ++- src/wp-links-opml.php | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/includes/export.php b/src/wp-admin/includes/export.php index 1c7694f0..ac673ec5 100755 --- a/src/wp-admin/includes/export.php +++ b/src/wp-admin/includes/export.php @@ -519,7 +519,8 @@ function wxr_filter_postmeta( $return_me, $meta_key ) { " /> diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php index b83d822f..2e3f8318 100755 --- a/src/wp-admin/options-discussion.php +++ b/src/wp-admin/options-discussion.php @@ -71,7 +71,8 @@
      diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 863a5093..cd37763d 100755 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -221,7 +221,8 @@ display( 'Name' ); if ( $description ) { - echo ': ' . $description;} + echo ': ' . $description; + } ?> diff --git a/src/wp-includes/feed-atom-comments.php b/src/wp-includes/feed-atom-comments.php index b43f8d4e..e11955f7 100755 --- a/src/wp-includes/feed-atom-comments.php +++ b/src/wp-includes/feed-atom-comments.php @@ -93,7 +93,8 @@ ' . get_comment_author_url() . '';} + echo '' . get_comment_author_url() . ''; + } ?> diff --git a/src/wp-includes/theme-compat/header.php b/src/wp-includes/theme-compat/header.php index daa0088d..cbd84eb2 100755 --- a/src/wp-includes/theme-compat/header.php +++ b/src/wp-includes/theme-compat/header.php @@ -43,7 +43,8 @@ diff --git a/src/wp-links-opml.php b/src/wp-links-opml.php index ca43c3d4..746c287a 100755 --- a/src/wp-links-opml.php +++ b/src/wp-links-opml.php @@ -83,7 +83,8 @@ Date: Sat, 26 Nov 2022 22:16:27 +0000 Subject: [PATCH 36/36] Docs: Add missing parameter descriptions in `wp-admin/includes/template.php`. Props mahekkalola, costdev, audrasjb, riccardodicurti. Fixes #57208. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@54883 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/template.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index aae3a262..dd3bd6e9 100755 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -260,7 +260,7 @@ function wp_popular_terms_checklist( $taxonomy, $default_term = 0, $number = 10, * * @since 2.5.1 * - * @param int $link_id + * @param int $link_id Optional. The link ID. Default 0. */ function wp_link_category_checklist( $link_id = 0 ) { $default = 1; @@ -402,10 +402,11 @@ function get_inline_data( $post ) { * * @global WP_List_Table $wp_list_table * - * @param int $position - * @param bool $checkbox - * @param string $mode - * @param bool $table_row + * @param int $position Optional. The value of the 'position' input field. Default 1. + * @param bool $checkbox Optional. The value of the 'checkbox' input field. Default false. + * @param string $mode Optional. If set to 'single', will use WP_Post_Comments_List_Table, + * otherwise WP_Comments_List_Table. Default 'single'. + * @param bool $table_row Optional. Whether to use a table instead of a div element. Default true. */ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { global $wp_list_table; @@ -565,7 +566,7 @@ function wp_comment_trashnotice() { * * @since 1.2.0 * - * @param array $meta + * @param array[] $meta An array of meta data arrays keyed on 'meta_key' and 'meta_value'. */ function list_meta( $meta ) { // Exit if no meta. @@ -609,9 +610,9 @@ function list_meta( $meta ) { * * @since 2.5.0 * - * @param array $entry - * @param int $count - * @return string + * @param array $entry An array of meta data keyed on 'meta_key' and 'meta_value'. + * @param int $count Reference to the row number. + * @return string A single row of public meta data. */ function _list_meta_row( $entry, &$count ) { static $update_nonce = ''; @@ -1876,7 +1877,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa * * @since 2.7.0 * - * @param string $found_action + * @param string $found_action Optional. The value of the 'found_action' input field. Default empty string. */ function find_posts_div( $found_action = '' ) { ?>