Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions src/wp-admin/includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ function screen_options( $screen ) {
* @see WP_Screen::render_screen_meta()
*/
function screen_meta( $screen ) {
_deprecated_function( __FUNCTION__, '3.3.0', 'WP_Screen::render_screen_meta()' );
$current_screen = get_current_screen();
$current_screen->render_screen_meta();
}
Expand Down Expand Up @@ -1252,64 +1253,82 @@ function get_screen_icon() {
* @since 2.5.0
* @deprecated 3.8.0
*/
function wp_dashboard_incoming_links_output() {}
function wp_dashboard_incoming_links_output() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard secondary output.
*
* @deprecated 3.8.0
*/
function wp_dashboard_secondary_output() {}
function wp_dashboard_secondary_output() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard widget controls.
*
* @since 2.7.0
* @deprecated 3.8.0
*/
function wp_dashboard_incoming_links() {}
function wp_dashboard_incoming_links() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard incoming links control.
*
* @deprecated 3.8.0
*/
function wp_dashboard_incoming_links_control() {}
function wp_dashboard_incoming_links_control() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard plugins control.
*
* @deprecated 3.8.0
*/
function wp_dashboard_plugins() {}
function wp_dashboard_plugins() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard primary control.
*
* @deprecated 3.8.0
*/
function wp_dashboard_primary_control() {}
function wp_dashboard_primary_control() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard recent comments control.
*
* @deprecated 3.8.0
*/
function wp_dashboard_recent_comments_control() {}
function wp_dashboard_recent_comments_control() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard secondary section.
*
* @deprecated 3.8.0
*/
function wp_dashboard_secondary() {}
function wp_dashboard_secondary() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Deprecated dashboard secondary control.
*
* @deprecated 3.8.0
*/
function wp_dashboard_secondary_control() {}
function wp_dashboard_secondary_control() {
_deprecated_function( __FUNCTION__, '3.8.0' );
}

/**
* Display plugins text for the WordPress news widget.
Expand Down Expand Up @@ -1505,6 +1524,7 @@ function post_form_autocomplete_off() {
* @deprecated 4.9.0
*/
function options_permalink_add_js() {
_deprecated_function( __FUNCTION__, '4.9.0' );
?>
<script type="text/javascript">
jQuery(document).ready(function() {
Expand Down
8 changes: 7 additions & 1 deletion src/wp-includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,7 @@ function get_usernumposts( $userid ) {
* @return string An HTML entity
*/
function funky_javascript_callback($matches) {
_deprecated_function( __FUNCTION__, '3.0.0' );
return "&#".base_convert($matches[1],16,10).";";
}

Expand Down Expand Up @@ -3301,7 +3302,9 @@ function user_pass_ok($user_login, $user_pass) {
* @since 2.3.0
* @deprecated 3.5.0
*/
function _save_post_hook() {}
function _save_post_hook() {
_deprecated_function( __FUNCTION__, '3.5.0' );
}

/**
* Check if the installed version of GD supports particular image type
Expand Down Expand Up @@ -3417,6 +3420,7 @@ function rich_edit_exists() {
* @return int Number of topics.
*/
function default_topic_count_text( $count ) {
_deprecated_function( __FUNCTION__, '3.9.0' );
return $count;
}

Expand Down Expand Up @@ -4106,6 +4110,7 @@ function remove_option_whitelist( $del_options, $options = '' ) {
* @return mixed Slashes $value
*/
function wp_slash_strings_only( $value ) {
_deprecated_function( __FUNCTION__, '5.6.0', 'wp_slash()' );
return map_deep( $value, 'addslashes_strings_only' );
}

Expand All @@ -4121,6 +4126,7 @@ function wp_slash_strings_only( $value ) {
* @return mixed
*/
function addslashes_strings_only( $value ) {
_deprecated_function( __FUNCTION__, '5.6.0', 'wp_slash()' );
return is_string( $value ) ? addslashes( $value ) : $value;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/import/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
* @group import
*/
class Tests_Import_Import extends WP_Import_UnitTestCase {

protected $expected_deprecated = array(
'wp_slash_strings_only',
'addslashes_strings_only',
);
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrfnl, @hellofromtonya All but one of the test methods in this class will expect deprecation notices for these functions.

By defining them here, it means that $this->expected_deprecated = array() can be called in the one test that doesn't expect these deprecation notices to occur, and doesn't apply to later tests in the class.

While this makes sense, I haven't seen this approach used in Core's test suite before, so I'm pinging for your thoughts. Note: This is also done in another file in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my two pennies:

I'm not keen on this as it obfuscates what's going on and effectively "hides" that the deprecation is being expected and tested for every single function (save one).

While it works, it requires a deep understanding of the test suite framework to understand what's going on, which makes these tests error prone going forward.

Copy link
Member

@jrfnl jrfnl Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a frustrated side-note (not to be actioned in this PR): why the heck is this even possible and why is the $expected_deprecated property in the WP_UnitTestCase_Base class protected instead of private ???

Copy link
Contributor

@costdev costdev Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jrfnl! I agree - While more verbose to add this to each of the related test methods:

* @expectedDeprecated wp_slash_strings_only
* @expectedDeprecated addslashes_strings_only

(cont.) it maintains consistency with the rest of the test suite, and makes it easier to read each test method in isolation and know exactly what should be expected without needing to review the rest of the test class.

As a frustrated side-note (not to be actioned in this PR): why the heck is this even possible and why is the $expected_deprecated property in the WP_UnitTestCase_Base class protected instead of private ???

Because you're too happy and it's important that codebases drop in these little easter eggs to disrupt the flow. 😂


public function set_up() {
parent::set_up();

Expand Down Expand Up @@ -243,6 +249,7 @@ public function test_double_import() {
}

public function test_ordering_of_importers() {
$this->expected_deprecated = array();
global $wp_importers;
$_wp_importers = $wp_importers; // Preserve global state.
$wp_importers = array(
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/import/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @group import
*/
class Tests_Import_Parser extends WP_Import_UnitTestCase {

public function set_up() {
parent::set_up();

Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/tests/import/postmeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @group import
*/
class Tests_Import_Postmeta extends WP_Import_UnitTestCase {
protected $expected_deprecated = array(
'wp_slash_strings_only',
'addslashes_strings_only',
);

public function set_up() {
parent::set_up();

Expand Down