[dev] A little fix for RPC.php (was:bug in Group.php ??)

René Lund Jensen lundeman@tbkol.dk
Mon Oct 28 10:48:41 2002


> Citat Jan Schneider <jan@horde.org>:
>
> > This is now fixed in CVS.
> >
> > Jan.
> >
>
> Thanx a million Jan...
>
> I just came across one difference from calling methods via RPC and
> callByPackage.
>
> The RPC server seems to wrap all parameters in an array.
> So that
> array('username' => 'lundeman')
> becomes
> array(array('username' => 'lundeman')
> this diff does the trick for me..
>
> Basicly it just takes the first entry of $params in _dispatcher
> and uses that when calling $registry->call().

I can't follow this. This is how I test the server:

$response = RPC::request('/headhorde/rpc.php', 'localhost', 80,
'contacts.search', array(array('jan'), array('localsql'), array('name',
'email')), Auth::getAuth(), Auth::getCredential('password'));

That's not the best example because contacts/search itself take arrays as
its parameter, but you get the point. All parameters to contacts/search are
passed in one array and the dispatcher get this parameter also as an array.
Registry::call() at the end of this chain also takes its parameters as an
array. Am I anything missing here?

Jan.

OK.. I don't have Turba installed (yet). And I've difficulties following
your example.
(I used to test with my own custom app, which may not be the best example
either..)
So lets use Nag to test with (it's more down to the basics).

with my fix these two calls give the same result.
(ain't that what we are aiming at..?)

require_once dirname(__FILE__) . '/../nag/lib/constants.php';
// Use callByPackage
$response = $registry->callByPackage('nag', 'list', array('sortby' =>
NAG_SORT_PRIORITY))
var_dump($response);

// Use XML_RPC
$response = RPC::request('/horde/rpc.php', 'horde.tbkol.dk', 80,
'tasks.list', array('sortby' => NAG_SORT_PRIORITY), Auth::getAuth(),
Auth::getCredential('password'));
var_dump($response);

BUT... when testing WITHOUT me fix they ALSO produce the same (right)
output.

Well.. my conclusion is.: I'll use the fix.
To get my custom app to work, it won't work without it,
and I don't have a clue to what I made different in my api, compared to nags
api.

Sorry about the noise..

Rene Jensen
lundeman@tbkol.dk