Skip to content

Commit eba54de

Browse files
committed
Update the minimum_wp_version to WP 5.8
The minimum version should be three versions behind the latest WP release, so what with 6.1 being out, it should now be 5.8. Includes adding a little more variation to the example code in the property docblock in the `MinimumWPVersionTrait`. Includes updating the list of deprecated functions in the `WP.DeprecatedFunctions` sniff based on the WP 6.1.1 release. Input for this based on @JDGrimes's WP deprecated code scanner, though that is getting more and more difficult to run as it is no longer maintained and is throwing lots of errors. Notes: * The `sanitize_url()` function has been _un_deprecated in WP 5.9. See 2031. * The replacement for the deprecated `wp_cache_reset()` function has been changed in WP Core. Ref: https://core.trac.wordpress.org/changeset/52705 * The `_filter_query_attachment_filenames()` function lists the wrong deprecation version in Core. WPCS now contains the correct version. A patch has been submitted to fix the listing in Core. Refs: - https://core.trac.wordpress.org/changeset/54524 - https://core.trac.wordpress.org/ticket/56791#comment:10 * Other than the above, no verification has been executed on the newly added deprecated function information. Includes minor tweak to make the generation of the test lines array a little more descriptive. Previous: 1881 Closes 2031
1 parent 20ce698 commit eba54de

File tree

6 files changed

+202
-28
lines changed

6 files changed

+202
-28
lines changed

WordPress/Helpers/MinimumWPVersionTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ trait MinimumWPVersionTrait {
4848
* Example usage:
4949
* <rule ref="WordPress.WP.DeprecatedClasses">
5050
* <properties>
51-
* <property name="minimum_wp_version" value="4.3"/>
51+
* <property name="minimum_wp_version" value="4.9"/>
5252
* </properties>
5353
* </rule>
5454
*
5555
* Alternatively, the value can be passed in one go for all sniffs using it via
5656
* the command line or by setting a `<config>` value in a custom phpcs.xml ruleset.
5757
*
58-
* CL: `phpcs --runtime-set minimum_wp_version 4.5`
59-
* Ruleset: `<config name="minimum_wp_version" value="4.5"/>`
58+
* CL: `phpcs --runtime-set minimum_wp_version 5.7`
59+
* Ruleset: `<config name="minimum_wp_version" value="6.0"/>`
6060
*
6161
* @since 0.14.0 Previously the individual sniffs each contained this property.
6262
* @since 3.0.0 - Moved from the Sniff class to this dedicated Trait.
@@ -68,7 +68,7 @@ trait MinimumWPVersionTrait {
6868
*
6969
* @var string WordPress version.
7070
*/
71-
public $minimum_wp_version = '5.1';
71+
public $minimum_wp_version = '5.8';
7272

7373
/**
7474
* Overrule the minimum supported WordPress version with a command-line/config value.

WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php

Lines changed: 132 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,6 @@ class DeprecatedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
410410
'alt' => 'wp_register_widget_control()',
411411
'version' => '2.8.0',
412412
),
413-
'sanitize_url' => array(
414-
'alt' => 'esc_url_raw()',
415-
'version' => '2.8.0',
416-
),
417413
'the_author_aim' => array(
418414
'alt' => 'the_author_meta(\'aim\')',
419415
'version' => '2.8.0',
@@ -988,7 +984,7 @@ class DeprecatedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
988984
'version' => '3.5.0',
989985
),
990986
'wp_cache_reset' => array(
991-
'alt' => 'WP_Object_Cache::reset()',
987+
'alt' => 'wp_cache_switch_to_blog()',
992988
'version' => '3.5.0',
993989
),
994990
'wp_create_thumbnail' => array(
@@ -1369,6 +1365,137 @@ class DeprecatedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
13691365
'alt' => 'wp_get_user_request()',
13701366
'version' => '5.4.0',
13711367
),
1368+
1369+
// WP 5.5.0.
1370+
'_wp_register_meta_args_whitelist' => array(
1371+
'alt' => '_wp_register_meta_args_allowed_list()',
1372+
'version' => '5.5.0',
1373+
),
1374+
'add_option_whitelist' => array(
1375+
'alt' => 'add_allowed_options()',
1376+
'version' => '5.5.0',
1377+
),
1378+
'remove_option_whitelist' => array(
1379+
'alt' => 'remove_allowed_options()',
1380+
'version' => '5.5.0',
1381+
),
1382+
'wp_blacklist_check' => array(
1383+
'alt' => 'wp_check_comment_disallowed_list()',
1384+
'version' => '5.5.0',
1385+
),
1386+
'wp_make_content_images_responsive' => array(
1387+
'alt' => 'wp_filter_content_tags()',
1388+
'version' => '5.5.0',
1389+
),
1390+
'wp_unregister_GLOBALS' => array(
1391+
'alt' => '',
1392+
'version' => '5.5.0',
1393+
),
1394+
1395+
// WP 5.7.0.
1396+
'noindex' => array(
1397+
'alt' => 'wp_robots_noindex()',
1398+
'version' => '5.7.0',
1399+
),
1400+
'wp_no_robots' => array(
1401+
'alt' => 'wp_robots_no_robots()',
1402+
'version' => '5.7.0',
1403+
),
1404+
'wp_sensitive_page_meta' => array(
1405+
'alt' => 'wp_robots_sensitive_page()',
1406+
'version' => '5.7.0',
1407+
),
1408+
1409+
// WP 5.8.0.
1410+
'_excerpt_render_inner_columns_blocks' => array(
1411+
'alt' => '_excerpt_render_inner_blocks()',
1412+
'version' => '5.8.0',
1413+
),
1414+
1415+
// WP 5.9.0.
1416+
'readonly' => array(
1417+
'alt' => 'wp_readonly()',
1418+
'version' => '5.9.0',
1419+
),
1420+
1421+
// WP 5.9.1.
1422+
'wp_render_duotone_filter_preset' => array(
1423+
'alt' => 'wp_get_duotone_filter_property()',
1424+
'version' => '5.9.1',
1425+
),
1426+
1427+
// WP 6.0.0.
1428+
'image_attachment_fields_to_save' => array(
1429+
'alt' => '',
1430+
'version' => '6.0.0',
1431+
),
1432+
'wp_add_iframed_editor_assets_html' => array(
1433+
'alt' => '',
1434+
'version' => '6.0.0',
1435+
),
1436+
'wp_skip_border_serialization' => array(
1437+
'alt' => 'wp_should_skip_block_supports_serialization()',
1438+
'version' => '6.0.0',
1439+
),
1440+
'wp_skip_dimensions_serialization' => array(
1441+
'alt' => 'wp_should_skip_block_supports_serialization()',
1442+
'version' => '6.0.0',
1443+
),
1444+
'wp_skip_spacing_serialization' => array(
1445+
'alt' => 'wp_should_skip_block_supports_serialization()',
1446+
'version' => '6.0.0',
1447+
),
1448+
1449+
// WP 6.0.2.
1450+
'the_meta' => array(
1451+
'alt' => 'get_post_meta()',
1452+
'version' => '6.0.2',
1453+
),
1454+
1455+
// WP 6.0.3.
1456+
// Verified; see https://core.trac.wordpress.org/ticket/56791#comment:10.
1457+
'_filter_query_attachment_filenames' => array(
1458+
'alt' => 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )',
1459+
'version' => '6.0.3',
1460+
),
1461+
1462+
// WP 6.1.0.
1463+
'_get_path_to_translation' => array(
1464+
'alt' => 'WP_Textdomain_Registry',
1465+
'version' => '6.1.0',
1466+
),
1467+
'_get_path_to_translation_from_lang_dir' => array(
1468+
'alt' => 'WP_Textdomain_Registry',
1469+
'version' => '6.1.0',
1470+
),
1471+
'_wp_multiple_block_styles' => array(
1472+
'alt' => '',
1473+
'version' => '6.1.0',
1474+
),
1475+
'global_terms' => array(
1476+
'alt' => '',
1477+
'version' => '6.1.0',
1478+
),
1479+
'global_terms_enabled' => array(
1480+
'alt' => '',
1481+
'version' => '6.1.0',
1482+
),
1483+
'install_global_terms' => array(
1484+
'alt' => '',
1485+
'version' => '6.1.0',
1486+
),
1487+
'sync_category_tag_slugs' => array(
1488+
'alt' => '',
1489+
'version' => '6.1.0',
1490+
),
1491+
'wp_get_attachment_thumb_file' => array(
1492+
'alt' => '',
1493+
'version' => '6.1.0',
1494+
),
1495+
'wp_typography_get_css_variable_inline_style' => array(
1496+
'alt' => 'wp_style_engine_get_styles()',
1497+
'version' => '6.1.0',
1498+
),
13721499
);
13731500

13741501
/**

WordPress/Tests/WP/DeprecatedClassesUnitTest.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,5 @@ $a = (new WP_User_Search())->query();
1616
/* ============ WP 4.9 ============ */
1717
class Prefix_Menu_section extends Customize_New_Menu_Section {}
1818
WP_Customize_New_Menu_Control::foo();
19-
20-
/*
21-
* Warning.
22-
*/
2319
/* ============ WP 5.3 ============ */
2420
$json = new Services_JSON;

WordPress/Tests/WP/DeprecatedClassesUnitTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ class DeprecatedClassesUnitTest extends AbstractSniffUnitTest {
2727
* @return array <int line number> => <int number of errors>
2828
*/
2929
public function getErrorList() {
30-
$errors = array_fill( 9, 10, 1 );
30+
$start_line = 9;
31+
$end_line = 20;
32+
$errors = array_fill( $start_line, ( ( $end_line - $start_line ) + 1 ), 1 );
3133

3234
// Unset the lines related to version comments.
33-
unset( $errors[16] );
35+
unset( $errors[16], $errors[19] );
3436

3537
return $errors;
3638
}
@@ -41,7 +43,7 @@ public function getErrorList() {
4143
* @return array <int line number> => <int number of warnings>
4244
*/
4345
public function getWarningList() {
44-
return array_fill( 24, 1, 1 );
46+
return array();
4547
}
4648

4749
}

WordPress/Tests/WP/DeprecatedFunctionsUnitTest.inc

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ get_the_author_yim();
9999
js_escape();
100100
register_sidebar_widget();
101101
register_widget_control();
102-
sanitize_url();
102+
sanitize_url(); // Undeprecated as of WP 5.9. See #2031.
103103
the_author_aim();
104104
the_author_description();
105105
the_author_email();
@@ -334,10 +334,6 @@ get_shortcut_link();
334334
is_user_option_local();
335335
wp_ajax_press_this_add_category();
336336
wp_ajax_press_this_save_post();
337-
338-
/*
339-
* Warning.
340-
*/
341337
/* ============ WP 5.1 ============ */
342338
insert_blog();
343339
install_blog();
@@ -347,3 +343,44 @@ _wp_privacy_requests_screen_options();
347343
update_user_status();
348344
/* ============ WP 5.4 ============ */
349345
wp_get_user_request_data();
346+
/* ============ WP 5.5 ============ */
347+
_wp_register_meta_args_whitelist();
348+
add_option_whitelist();
349+
remove_option_whitelist();
350+
wp_blacklist_check();
351+
wp_make_content_images_responsive();
352+
wp_unregister_GLOBALS();
353+
/* ============ WP 5.7 ============ */
354+
noindex();
355+
wp_no_robots();
356+
wp_sensitive_page_meta();
357+
358+
/*
359+
* Warning.
360+
*/
361+
/* ============ WP 5.8 ============ */
362+
_excerpt_render_inner_columns_blocks();
363+
/* ============ WP 5.9 ============ */
364+
readonly();
365+
/* ============ WP 5.9.1 ============ */
366+
wp_render_duotone_filter_preset();
367+
/* ============ WP 6.0 ============ */
368+
image_attachment_fields_to_save();
369+
wp_add_iframed_editor_assets_html();
370+
wp_skip_border_serialization();
371+
wp_skip_dimensions_serialization();
372+
wp_skip_spacing_serialization();
373+
/* ============ WP 6.0.2 ============ */
374+
the_meta();
375+
/* ============ WP 6.0.3 ============ */
376+
_filter_query_attachment_filenames();
377+
/* ============ WP 6.1 ============ */
378+
_get_path_to_translation();
379+
_get_path_to_translation_from_lang_dir();
380+
_wp_multiple_block_styles();
381+
global_terms();
382+
global_terms_enabled();
383+
install_global_terms();
384+
sync_category_tag_slugs();
385+
wp_get_attachment_thumb_file();
386+
wp_typography_get_css_variable_inline_style();

WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest {
2727
* @return array <int line number> => <int number of errors>
2828
*/
2929
public function getErrorList() {
30-
31-
$errors = array_fill( 8, 329, 1 );
30+
$start_line = 8;
31+
$end_line = 356;
32+
$errors = array_fill( $start_line, ( ( $end_line - $start_line ) + 1 ), 1 );
3233

3334
// Unset the lines related to version comments.
3435
unset(
@@ -43,6 +44,7 @@ public function getErrorList() {
4344
$errors[73],
4445
$errors[76],
4546
$errors[80],
47+
$errors[102], // Undeprecated function.
4648
$errors[118],
4749
$errors[125],
4850
$errors[162],
@@ -63,7 +65,12 @@ public function getErrorList() {
6365
$errors[319],
6466
$errors[323],
6567
$errors[330],
66-
$errors[332]
68+
$errors[332],
69+
$errors[337],
70+
$errors[340],
71+
$errors[344],
72+
$errors[346],
73+
$errors[353]
6774
);
6875

6976
return $errors;
@@ -75,13 +82,18 @@ public function getErrorList() {
7582
* @return array <int line number> => <int number of warnings>
7683
*/
7784
public function getWarningList() {
78-
79-
$warnings = array_fill( 342, 8, 1 );
85+
$start_line = 362;
86+
$end_line = 386;
87+
$warnings = array_fill( $start_line, ( ( $end_line - $start_line ) + 1 ), 1 );
8088

8189
// Unset the lines related to version comments.
8290
unset(
83-
$warnings[344],
84-
$warnings[348]
91+
$warnings[363],
92+
$warnings[365],
93+
$warnings[367],
94+
$warnings[373],
95+
$warnings[375],
96+
$warnings[377]
8597
);
8698

8799
return $warnings;

0 commit comments

Comments
 (0)