mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
General: Restore usage of $wpdb, instead of $this->db.
Hiding the `$wpdb` global behind a property decreases the readability of the code, as well as causing irrelevant output when dumping an object. Reverts [38275], [38278], [38279], [38280], [38387]. See #37699. git-svn-id: https://develop.svn.wordpress.org/trunk@38768 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -53,13 +53,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*/
|
||||
protected $auth_failed = false;
|
||||
|
||||
/**
|
||||
* @since 4.7.0
|
||||
* @access protected
|
||||
* @var wpdb
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Registers all of the XMLRPC methods that XMLRPC server understands.
|
||||
*
|
||||
@@ -70,8 +63,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->db = $GLOBALS['wpdb'];
|
||||
|
||||
$this->methods = array(
|
||||
// WordPress API
|
||||
'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
|
||||
@@ -2894,6 +2885,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param array $args {
|
||||
* Method arguments. Note: arguments must be ordered as documented.
|
||||
*
|
||||
@@ -2904,6 +2897,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* @return array|IXR_Error
|
||||
*/
|
||||
public function wp_getPageList( $args ) {
|
||||
global $wpdb;
|
||||
|
||||
$this->escape( $args );
|
||||
|
||||
$username = $args[1];
|
||||
@@ -2919,14 +2914,14 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
do_action( 'xmlrpc_call', 'wp.getPageList' );
|
||||
|
||||
// Get list of pages ids and titles
|
||||
$page_list = $this->db->get_results("
|
||||
$page_list = $wpdb->get_results("
|
||||
SELECT ID page_id,
|
||||
post_title page_title,
|
||||
post_parent page_parent_id,
|
||||
post_date_gmt,
|
||||
post_date,
|
||||
post_status
|
||||
FROM {$this->db->posts}
|
||||
FROM {$wpdb->posts}
|
||||
WHERE post_type = 'page'
|
||||
ORDER BY ID
|
||||
");
|
||||
@@ -5143,17 +5138,20 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $post_ID Post ID.
|
||||
* @param string $post_content Post Content for attachment.
|
||||
*/
|
||||
public function attach_uploads( $post_ID, $post_content ) {
|
||||
global $wpdb;
|
||||
|
||||
// find any unattached files
|
||||
$attachments = $this->db->get_results( "SELECT ID, guid FROM {$this->db->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
|
||||
$attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
|
||||
if ( is_array( $attachments ) ) {
|
||||
foreach ( $attachments as $file ) {
|
||||
if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) {
|
||||
$this->db->update( $this->db->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) );
|
||||
}
|
||||
if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false )
|
||||
$wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5773,6 +5771,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param array $args {
|
||||
* Method arguments. Note: arguments must be ordered as documented.
|
||||
*
|
||||
@@ -5784,6 +5784,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* @return array|IXR_Error
|
||||
*/
|
||||
public function mw_newMediaObject( $args ) {
|
||||
global $wpdb;
|
||||
|
||||
$username = $this->escape( $args[1] );
|
||||
$password = $this->escape( $args[2] );
|
||||
$data = $args[3];
|
||||
@@ -6109,10 +6111,14 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $post_ID
|
||||
* @return array|IXR_Error
|
||||
*/
|
||||
public function mt_getTrackbackPings( $post_ID ) {
|
||||
global $wpdb;
|
||||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'mt.getTrackbackPings' );
|
||||
|
||||
@@ -6121,7 +6127,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if ( !$actual_post )
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
|
||||
$comments = $this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments} WHERE comment_post_ID = %d", $post_ID) );
|
||||
$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
|
||||
|
||||
if ( !$comments )
|
||||
return array();
|
||||
@@ -6256,8 +6262,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
} elseif ( is_string($urltest['fragment']) ) {
|
||||
// ...or a string #title, a little more complicated
|
||||
$title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
|
||||
$sql = $this->db->prepare("SELECT ID FROM {$this->db->posts} WHERE post_title RLIKE %s", $title );
|
||||
if (! ($post_ID = $this->db->get_var($sql)) ) {
|
||||
$sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
|
||||
if (! ($post_ID = $wpdb->get_var($sql)) ) {
|
||||
// returning unknown error '0' is better than die()ing
|
||||
return $this->pingback_error( 0, '' );
|
||||
}
|
||||
@@ -6281,7 +6287,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) );
|
||||
|
||||
// Let's check that the remote site didn't already pingback this entry
|
||||
if ( $this->db->get_results( $this->db->prepare("SELECT * FROM {$this->db->comments} WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
|
||||
if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
|
||||
return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
|
||||
|
||||
// very stupid, but gives time to the 'from' server to publish !
|
||||
@@ -6408,10 +6414,14 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $url
|
||||
* @return array|IXR_Error
|
||||
*/
|
||||
public function pingback_extensions_getPingbacks( $url ) {
|
||||
global $wpdb;
|
||||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' );
|
||||
|
||||
@@ -6430,7 +6440,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->pingback_error( 32, __('The specified target URL does not exist.' ) );
|
||||
}
|
||||
|
||||
$comments = $this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments} WHERE comment_post_ID = %d", $post_ID) );
|
||||
$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
|
||||
|
||||
if ( !$comments )
|
||||
return array();
|
||||
|
||||
Reference in New Issue
Block a user