From 51700c716f3898578434f3097252ffb91a22ea48 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sat, 20 Jul 2019 18:14:07 +0200
Subject: [PATCH] Simplify & modernize *::__call()
The callback in these functions is always checked against a limited list of valid callbacks and those are not problematic, so these can be safely changed to dynamic function calls.
---
src/wp-admin/includes/class-wp-list-table.php | 2 +-
src/wp-includes/class-wp-comment-query.php | 2 +-
src/wp-includes/class-wp-oembed.php | 2 +-
src/wp-includes/class-wp-query.php | 2 +-
src/wp-includes/class-wp-roles.php | 2 +-
src/wp-includes/class-wp-user-query.php | 2 +-
src/wp-includes/class-wp-user.php | 2 +-
src/wp-includes/class-wp-xmlrpc-server.php | 2 +-
8 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php
index 021547fd18..0994e197ea 100644
|
a
|
b
|
class WP_List_Table { |
| 239 | 239 | */ |
| 240 | 240 | public function __call( $name, $arguments ) { |
| 241 | 241 | if ( in_array( $name, $this->compat_methods ) ) { |
| 242 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 242 | return $this->$name( ...$arguments ); |
| 243 | 243 | } |
| 244 | 244 | return false; |
| 245 | 245 | } |
diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
index eba9ddf54e..7e055fc1b1 100644
|
a
|
b
|
class WP_Comment_Query { |
| 124 | 124 | */ |
| 125 | 125 | public function __call( $name, $arguments ) { |
| 126 | 126 | if ( 'get_search_sql' === $name ) { |
| 127 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 127 | return $this->get_search_sql( ...$arguments ); |
| 128 | 128 | } |
| 129 | 129 | return false; |
| 130 | 130 | } |
diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php
index dce67fcb41..ffbdb45b0e 100644
|
a
|
b
|
class WP_oEmbed { |
| 235 | 235 | */ |
| 236 | 236 | public function __call( $name, $arguments ) { |
| 237 | 237 | if ( in_array( $name, $this->compat_methods ) ) { |
| 238 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 238 | return $this->$name( ...$arguments ); |
| 239 | 239 | } |
| 240 | 240 | return false; |
| 241 | 241 | } |
diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php
index 3d7374cf93..6da6909a86 100644
|
a
|
b
|
class WP_Query { |
| 3560 | 3560 | */ |
| 3561 | 3561 | public function __call( $name, $arguments ) { |
| 3562 | 3562 | if ( in_array( $name, $this->compat_methods ) ) { |
| 3563 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 3563 | return $this->$name( ...$arguments ); |
| 3564 | 3564 | } |
| 3565 | 3565 | return false; |
| 3566 | 3566 | } |
diff --git a/src/wp-includes/class-wp-roles.php b/src/wp-includes/class-wp-roles.php
index 18b0d55035..6e3004c37c 100644
|
a
|
b
|
class WP_Roles { |
| 101 | 101 | */ |
| 102 | 102 | public function __call( $name, $arguments ) { |
| 103 | 103 | if ( '_init' === $name ) { |
| 104 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 104 | return $this->_init( ...$arguments ); |
| 105 | 105 | } |
| 106 | 106 | return false; |
| 107 | 107 | } |
diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php
index 33408e51d0..56a0dce6bd 100644
|
a
|
b
|
class WP_User_Query { |
| 885 | 885 | */ |
| 886 | 886 | public function __call( $name, $arguments ) { |
| 887 | 887 | if ( 'get_search_sql' === $name ) { |
| 888 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 888 | return $this->get_search_sql( ...$arguments ); |
| 889 | 889 | } |
| 890 | 890 | return false; |
| 891 | 891 | } |
diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php
index 73f7cdf0d5..a1c2b6e2c4 100644
|
a
|
b
|
class WP_User { |
| 444 | 444 | */ |
| 445 | 445 | public function __call( $name, $arguments ) { |
| 446 | 446 | if ( '_init_caps' === $name ) { |
| 447 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 447 | return $this->_init_caps( ...$arguments ); |
| 448 | 448 | } |
| 449 | 449 | return false; |
| 450 | 450 | } |
diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
index 72aeef2048..8dfc737231 100644
|
a
|
b
|
class wp_xmlrpc_server extends IXR_Server { |
| 177 | 177 | */ |
| 178 | 178 | public function __call( $name, $arguments ) { |
| 179 | 179 | if ( '_multisite_getUsersBlogs' === $name ) { |
| 180 | | return call_user_func_array( array( $this, $name ), $arguments ); |
| | 180 | return $this->_multisite_getUsersBlogs( ...$arguments ); |
| 181 | 181 | } |
| 182 | 182 | return false; |
| 183 | 183 | } |