Hello Diogene,

Diogene Laerce <[EMAIL PROTECTED]> writes:

> But the debug answers that vote function takes 4 arguments ?? where the
> demexp doc says :
>
> vote(cookie_t, question_id_t, vote_choice_t) ??
>
> Any explanation ? 

Yes. If you give a wrongly encoded value to "new xmlrpcmsg()", it
*silently* skips the value without doing any warning. Thus the missing
argment[1]. In your case, your where constructing wrongly the array
argument ($vote_user).

Please find attached two files. Firstly, the original code you
submitted, augmented so that it works here to reproduce your issue. Then
the second one with modifications I made. I basically rewrote the steps
to construct the array argument. You must create an *empty* array and
then *just call* the method addScalar() on this array.

By the way, you should use the method call setDebug(2) on the
xmlrpc_client() object: it gives the content of the call sent to the
server, very useful for the debug!

Here are the modified lines:

--- vote-diogene.php    2008-02-24 21:45:33.000000000 +0100
+++ vote-diogene-dm1.php        2008-02-24 21:45:44.000000000 +0100
@@ -8,7 +8,7 @@
 xmlrpc_client("http://www.linux-france.org/cgi-bin/demexp-xmlrpc-test";);
 
 // mode debug
-$server->setDebug(1);
+$server->setDebug(2); ## Use level 2 so we see the requests made to the server
 
 print "## login ##";
 // login
@@ -28,14 +28,15 @@
 $cookie = new xmlrpcval($cookie_dm, "int");
 $question_id_t = new xmlrpcval($q_id, "int");
 
-$vote_user = new xmlrpcval("array");
-$count = count($vote_array);
+$vote_user = new xmlrpcval(array(), "array");
 
 $vote_array[0] = 1;
 $vote_array[1] = 0;
+$count = count($vote_array);
+
 for($i=0; $i<$count; $i++)
 {
-       $vote_user = $vote_user->addScalar($vote_array[$i], "int");
+  $vote_user->addScalar($vote_array[$i], "int");
 }
 
 $message = new xmlrpcmsg('vote', array($cookie, $question_id_t,



Footnotes: 
[1]  I would consider a serious design issue with PHP and this library.

-- 
GPG/PGP key: A3AD7A2A David MENTRE <[EMAIL PROTECTED]>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A

Attachment: vote-diogene.php
Description: application/httpd-php

Attachment: vote-diogene-dm1.php
Description: application/httpd-php

_______________________________________________
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev

Répondre à