Ticket #735 (closed defect: wontfix)

Opened 10 months ago

Last modified 3 months ago

XMLRPC 'blogger.getUsersBlogs' not working with a password protected blog

Reported by: GIGALinux Assigned to: donncha
Priority: highest Milestone: 2.7.1
Component: XML-RPC Version: 2.7
Severity: blocker Keywords:
Cc:

Description

If your WPMU installation has more than one site, the xml-pc function 'blogger.getUsersBlogs' doesn't work properly (No blogs will be returned). But - I've written a plugin that replaces the function with one that works (-> repair_xmlrpc.php).

Attachments

repair_xmlrpc.php (2.1 kB) - added by GIGALinux on 09/10/08 19:19:33.
xmlrpc_bug.diff (1.9 kB) - added by GIGALinux on 09/22/08 16:03:14.
xmlrpc_bug_2.diff (1.5 kB) - added by GIGALinux on 09/22/08 16:31:22.

Change History

09/10/08 19:19:33 changed by GIGALinux

  • attachment repair_xmlrpc.php added.

09/10/08 22:00:50 changed by josephscott

I'm not sure exactly what the problem is. Are you saying that if you have more than one blog in WPMU blogger.getUsersBlogs isn't working?

That would be sort of true. I wrote a post that covers some of that:

http://joseph.randomnetworks.com/archives/2008/06/10/blog-id-in-wordpress-and-xml-rpc-blog-apis/

09/16/08 17:14:02 changed by GIGALinux

  • summary changed from XMLRPC 'blogger.getUsersBlogs' not working with more then one site to XMLRPC 'blogger.getUsersBlogs' not working with a password protected blog.

My problem was not that i have more then one site. My problem ist that my blogs in a sandbox and with a .htaccess password protected. But the current function uses a http request to get the blogs. My new function gets the blogs direct without http request like it xmlrpc.php does.

(in reply to: ↑ description ) 09/17/08 15:19:26 changed by jorgerivas

Replying to GIGALinux:

But - I've written a plugin that replaces the function with one that works...

Just to clarify... is this a plugin or a modification to the xmlrpc.php file? The first few lines in the php file doesn't seem to follow "standard" plugin conventions.

If it should be inserted into the xmlrpc.php file, please indicate which line.

WPmu v2.6.1., PHP v5.1

Thanks, Jorge

09/17/08 15:22:06 changed by GIGALinux

This is a mu-plugin. (For mu-plugins you don't need the normal plugin header)

09/17/08 15:24:01 changed by GIGALinux

This plugin replaces nothing in the xmlrpc.php. It's replace the function wpmu_blogger_getUsersBlogs in wpmu-functions.php:1858

09/17/08 15:44:43 changed by josephscott

This seems like a rather odd case. You're preventing HTTP access to the XML-RPC end point via htpasswd, probably requiring HTTP basic auth. As the XML-RPC methods include inline authentication (username/password are part of the method calls) I think you'll find that XML-RPC clients will fail as well.

09/17/08 15:54:06 changed by GIGALinux

function wpmu_blogger_getUsersBlogs($args) {
	$site_details = get_blog_details( 1, true );
	$domain = $site_details->domain;
	$path = $site_details->path . 'xmlrpc.php';

	$rpc = new IXR_Client("http://{$domain}{$path}");
	$rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
	$blogs = $rpc->getResponse();

	if ( isset($blogs['faultCode']) ) {
		return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
	}

	if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
		return $blogs;
	} else {
		foreach ( (array) $blogs as $blog ) {
			if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
				return array($blog);
		}
		return array();
	}
}

function attach_wpmu_xmlrpc($methods) {
	$methods['blogger.getUsersBlogs'] = 'wpmu_blogger_getUsersBlogs';
	return $methods;
}
add_filter('xmlrpc_methods', 'attach_wpmu_xmlrpc');

No, my blogs are with a http basic auth protected - and xmlrpc.php. All xmlrpc methods are working, but not blogger.getUsersBlogs, because in wpmu-functions.php:1858 the function 'wpmu_blogger_getUsersBlogs' replaces the blogger_getUserBlogs method in xmlrpc.php, but wpmu_blogger_getUsersBlogs() is not working if the blogs are with a http basic auth protected.

09/17/08 16:19:51 changed by jorgerivas

@GIGALinux - thank you for the clarification. This mu-plugin worked for me. Prior to this change I was having issues posting with Windows Live Writer 2008 and ScribeFire? v3 blog clients. Both of these are working properly now. Thank you once again. Jorge

09/19/08 17:01:32 changed by donncha

  • status changed from new to assigned.

I've adapted the core code so it calls wp_getUsersBlogs() directly in the blogger getuserblogs function. Can you give that a go?

jorgerivas - I also removed a check for site_id != 1 in xmlrpc.php. The files are below, but you may need to be selective in what you merge with your own code if you're not running the latest 2.6 branch code. Appreciate if you could test this please!

http://trac.mu.wordpress.org/browser/branches/2.6/xmlrpc.php http://trac.mu.wordpress.org/browser/branches/2.6/wp-includes/wpmu-functions.php

09/19/08 17:40:54 changed by GIGALinux

Windows Live Writer says: "Invaild response document returned from XmlRpc? server".

I'll check the xmlrpc.log later.

09/19/08 17:42:33 changed by GIGALinux

This is the problem:

Fatal error: Call to undefined function wp_getUsersBlogs() in /xxx/wp-includes/wpmu-functions.php on line 1893

09/19/08 21:26:23 changed by donncha

GIGALinux - thanks, I forgot the xmlrpc object, can you update your wpmu-functions.php from the file above?

09/19/08 21:45:47 changed by GIGALinux

Only for you! ;)

Fatal error: Call to a member function wp_getUsersBlogs() on a non-object in /xy/wp-includes/wpmu-functions.php on line 1894

09/19/08 21:47:07 changed by GIGALinux

Little debug info: var_dump($wp_xmlrpc_server); = NULL

09/22/08 15:47:28 changed by donncha

  • status changed from assigned to closed.
  • resolution set to wontfix.

Unfortunately it looks like calling "wp.getUsersBlogs" directly doesn't work, no matter what I tried. Posting via xmlrpc to http password protected servers is such an edge case that I'm going to close this bug as the original issue with multiple sites is now working.

09/22/08 15:50:02 changed by donncha

Fixed multiple sites issue in [1491]

09/22/08 16:03:14 changed by GIGALinux

  • attachment xmlrpc_bug.diff added.

09/22/08 16:03:47 changed by GIGALinux

  • status changed from closed to reopened.
  • resolution deleted.

No, with this patch it working.

09/22/08 16:05:20 changed by donncha

But it repeats the code that's already in xmlrpc.php which is messy.

09/22/08 16:06:51 changed by GIGALinux

But it working. It's shows all blogs from a user without a extra http call.

09/22/08 16:10:07 changed by donncha

If you can patch wpmu-function.php without repeating the code in xmlrpc.php I'll include it.

09/22/08 16:10:47 changed by GIGALinux

In the 2.6 trunk the function attach_wpmu_xmlrpc is not active. It's missing a add_filter. This mean, that this function is needless, because the xmlrpc.php has all that the wpmu user need build in.

09/22/08 16:16:27 changed by GIGALinux

My bad, without the filter it's not working.

09/22/08 16:31:22 changed by GIGALinux

  • attachment xmlrpc_bug_2.diff added.

09/22/08 16:31:46 changed by GIGALinux

Try this new patch

01/09/09 06:10:48 changed by GIGALinux

  • version changed from 1.0 to 2.7.
  • component changed from component1 to XML-RPC.
  • milestone changed from WPMU 1.0 to 2.7.

donncha, has you checked the 2th patch?

01/30/09 22:45:47 changed by jamescollins

  • milestone changed from 2.7 to 2.7.1.

04/15/09 20:40:39 changed by techlover

Anything going on with this. It's been inactive for over 3 months.

04/15/09 20:44:36 changed by GIGALinux

  • status changed from reopened to closed.
  • resolution set to wontfix.

The problem is still open, I'm fixing it with a plugin, but I think I have only this problem. Closing it.