Properly deprecate both constructors in WP_User_Search.

- `__construct()` gets the new `_deprecated_class()` function
- `WP_User_Search` PHP4 style constructor is changed from `_deprecated_function()` to `_deprecated_constructor()`

Adds a test to confirm `WP_User_Search` class is testable as deprecated.

Props jrf, DrewAPicture.
Fixes #41125.


git-svn-id: https://develop.svn.wordpress.org/trunk@56469 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes
2023-08-25 03:35:59 +00:00
parent 515634ffff
commit 8fd9604f14
2 changed files with 16 additions and 1 deletions

View File

@@ -493,7 +493,7 @@ class WP_User_Search {
* @return WP_User_Search
*/
function __construct( $search_term = '', $page = '', $role = '' ) {
_deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
_deprecated_class( 'WP_User_Search', '3.1.0', 'WP_User_Query' );
$this->search_term = wp_unslash( $search_term );
$this->raw_page = ( '' == $page ) ? false : (int) $page;
@@ -516,6 +516,7 @@ class WP_User_Search {
* @return WP_User_Search
*/
public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
_deprecated_constructor( 'WP_User_Search', '3.1.0', get_class( $this ) );
self::__construct( $search_term, $page, $role );
}

View File

@@ -0,0 +1,14 @@
<?php
/**
* @coversDefaultClass WP_User_Search
*/
class Tests_Admin_wpUserSearch extends WP_UnitTestCase{
/**
* @covers ::__construct()
* @expectedDeprecated WP_User_Search
*/
public function test_class_is_deprecated() {
$wp_user_search = new WP_User_Search();
}
}