IXR 0.71. Props jacobsantos. fixes #7227

git-svn-id: https://develop.svn.wordpress.org/trunk@8376 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-07-19 17:56:35 +00:00
parent 7a97c74168
commit 9ba30a1b30
3 changed files with 46 additions and 23 deletions

View File

@ -22,6 +22,7 @@
class IXR_Value { class IXR_Value {
var $data; var $data;
var $type; var $type;
function IXR_Value ($data, $type = false) { function IXR_Value ($data, $type = false) {
$this->data = $data; $this->data = $data;
if (!$type) { if (!$type) {
@ -40,6 +41,7 @@ class IXR_Value {
} }
} }
} }
function calculateType() { function calculateType() {
if ($this->data === true || $this->data === false) { if ($this->data === true || $this->data === false) {
return 'boolean'; return 'boolean';
@ -73,6 +75,7 @@ class IXR_Value {
return 'array'; return 'array';
} }
} }
function getXml() { function getXml() {
/* Return XML for this value */ /* Return XML for this value */
switch ($this->type) { switch ($this->type) {
@ -113,6 +116,7 @@ class IXR_Value {
} }
return false; return false;
} }
function isStruct($array) { function isStruct($array) {
/* Nasty function to check if an array is a struct or not */ /* Nasty function to check if an array is a struct or not */
$expected = 0; $expected = 0;
@ -180,7 +184,7 @@ class IXR_Message {
return true; return true;
} }
function tag_open($parser, $tag, $attr) { function tag_open($parser, $tag, $attr) {
$this->_currentTagContents = ''; $this->_currentTagContents = '';
$this->currentTag = $tag; $this->currentTag = $tag;
switch($tag) { switch($tag) {
case 'methodCall': case 'methodCall':
@ -270,7 +274,7 @@ class IXR_Message {
$this->params[] = $value; $this->params[] = $value;
} }
} }
$this->_currentTagContents = ''; $this->_currentTagContents = '';
} }
} }
@ -334,7 +338,8 @@ EOD;
} }
function call($methodname, $args) { function call($methodname, $args) {
if (!$this->hasMethod($methodname)) { if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.'); return new IXR_Error(-32601, 'server error. requested method '.
$methodname.' does not exist.');
} }
$method = $this->callbacks[$methodname]; $method = $this->callbacks[$methodname];
// Perform the callback and send the response // Perform the callback and send the response
@ -347,18 +352,21 @@ EOD;
// It's a class method - check it exists // It's a class method - check it exists
$method = substr($method, 5); $method = substr($method, 5);
if (!method_exists($this, $method)) { if (!method_exists($this, $method)) {
return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.'); return new IXR_Error(-32601, 'server error. requested class method "'.
$method.'" does not exist.');
} }
// Call the method // Call the method
$result = $this->$method($args); $result = $this->$method($args);
} else { } else {
// It's a function - does it exist? // It's a function - does it exist?
if (is_array($method)) { if (is_array($method)) {
if (!method_exists($method[0], $method[1])) { if (!method_exists($method[0], $method[1])) {
return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); return new IXR_Error(-32601, 'server error. requested object method "'.
} $method[1].'" does not exist.');
}
} else if (!function_exists($method)) { } else if (!function_exists($method)) {
return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.'); return new IXR_Error(-32601, 'server error. requested function "'.
$method.'" does not exist.');
} }
// Call the function // Call the function
$result = call_user_func($method, $args); $result = call_user_func($method, $args);
@ -490,7 +498,7 @@ class IXR_Client {
var $response; var $response;
var $message = false; var $message = false;
var $debug = false; var $debug = false;
var $timeout; var $timeout;
// Storage place for an error message // Storage place for an error message
var $error = false; var $error = false;
function IXR_Client($server, $path = false, $port = 80, $timeout = false) { function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
@ -509,8 +517,8 @@ class IXR_Client {
$this->path = $path; $this->path = $path;
$this->port = $port; $this->port = $port;
} }
$this->useragent = 'Incutio XML-RPC'; $this->useragent = 'The Incutio XML-RPC PHP Library';
$this->timeout = $timeout; $this->timeout = $timeout;
} }
function query() { function query() {
$args = func_get_args(); $args = func_get_args();
@ -556,7 +564,7 @@ class IXR_Client {
$gettingHeaders = false; $gettingHeaders = false;
} }
if (!$gettingHeaders) { if (!$gettingHeaders) {
$contents .= trim($line)."\n"; $contents .= trim($line);
} }
} }
if ($this->debug) { if ($this->debug) {
@ -603,7 +611,7 @@ class IXR_Error {
var $message; var $message;
function IXR_Error($code, $message) { function IXR_Error($code, $message) {
$this->code = $code; $this->code = $code;
$this->message = htmlspecialchars($message); $this->message = $message;
} }
function getXml() { function getXml() {
$xml = <<<EOD $xml = <<<EOD
@ -665,10 +673,9 @@ class IXR_Date {
$this->hour = substr($iso, 9, 2); $this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2); $this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2); $this->second = substr($iso, 15, 2);
$this->timezone = substr($iso, 17);
} }
function getIso() { function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
} }
function getXml() { function getXml() {
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>'; return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';

View File

@ -761,20 +761,36 @@ function &get_terms($taxonomies, $args = '') {
function is_term($term, $taxonomy = '') { function is_term($term, $taxonomy = '') {
global $wpdb; global $wpdb;
$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
if ( is_int($term) ) { if ( is_int($term) ) {
if ( 0 == $term ) if ( 0 == $term )
return 0; return 0;
$where = 't.term_id = %d'; $where = 't.term_id = %d';
} else { if ( !empty($taxonomy) )
if ( '' === $term = sanitize_title($term) ) return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
return 0; else
$where = 't.slug = %s'; return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
} }
if ( !empty($taxonomy) ) if ( '' === $slug = sanitize_title($term) )
return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); return 0;
return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $term) ); $where = 't.slug = %s';
$else_where = 't.name = %s';
if ( !empty($taxonomy) ) {
if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) )
return $result;
return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
}
if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $slug) ) )
return $result;
return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $term) );
} }
/** /**

View File

@ -15,6 +15,6 @@ $wp_version = '2.7-bleeding';
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 8202; $wp_db_version = 8370;
?> ?>