[drupal-devel] [task] Rewrite to use procedures and conditionally
include xmlrpc.inc
jvandyk
drupal-devel at drupal.org
Mon Jan 31 23:22:21 UTC 2005
Project: Drupal
Version: cvs
Component: base system
Category: tasks
Priority: normal
Assigned to: walkah
Reported by: killes at www.drop.org
Updated by: jvandyk
Status: patch
This patch affects the inclusion of xmlrpc, which is the xmlrpc client,
not xmlrpcs, which is the server and subject to the "all XML-RPC
requests are POST requests" rule. Thus, it is ineffective.
However, we should consider eliminating the inclusion of xmlrpc.inc at
all in common.inc.
This would speed up Drupal at the expense of modules that use XML-RPC
calls having to include xmlrpc.inc themselves.
grepping for xmlrpc_ finds occurrences in drupal.module for
cross-drupal-site authentication, foaf.module, livejournalmodule, and
waypath.module.
jvandyk
Previous comments:
------------------------------------------------------------------------
April 29, 2004 - 18:15 : killes at www.drop.org
Drupal includes xmlrpc.inc for every non-cached page view. However, the
functions from the file are only rarely used. Therefore we need a patch
that includes the file from the functions that want to use it.
------------------------------------------------------------------------
May 2, 2004 - 18:30 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc.patch (4.64 KB)
Here is a patch that moves the include statement to the functiosn where
xmlrpc.inc is actually needed. The patch coul dneed some testing as I
do not use those modules (ping, bloggerapi) myself.
------------------------------------------------------------------------
May 3, 2004 - 21:34 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc_0.patch (6.38 KB)
Patch updated, I had forgotten drupal.module. thanks to crschmidt for
spotting this.
------------------------------------------------------------------------
May 3, 2004 - 22:17 : Steven
drupal_xml_parser_create() does not require xmlrpc.inc...
------------------------------------------------------------------------
May 3, 2004 - 22:27 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc_1.patch (6.06 KB)
Ok, updated.
------------------------------------------------------------------------
May 3, 2004 - 22:41 : Dries
If xmlrpc.php includes xmlrpc.inc, why do we have to include it in
blogapi module's functions once more? Also, the inclusion of
xmlrpc.inc in drupal.module can probably be avoided by including
xmlrpc.inc in cron.php? Am I missing something?
------------------------------------------------------------------------
May 3, 2004 - 22:49 : crschmidt
Not all of the tasks in drupal.module are run with cron.php: for
example, the distributed authentication comes in through drupal.module,
which requires code from xmlrpc.inc to create the messages it sends out,
as far as I can tell.
So, the drupal.module needs it for distributed authentication stuff,
not just for pinging servers and so on.
------------------------------------------------------------------------
May 3, 2004 - 23:38 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc_2.patch (2.8 KB)
"If xmlrpc.php includes xmlrpc.inc, why do we have to include it in
blogapi module's functions once more?"
As I said, I am not that familiar with that part of Drupal, did not
investigate under whch circumstances blogapi functions could be called,
and wanted to stay on the safe side. If you are sure that blogapi is
always called from xmlrpcs.php, then apply the appended version.
------------------------------------------------------------------------
May 4, 2004 - 05:40 : Dries
I'm not 100% sure either, I was merely suggesting an alternative. I
think the second patch might work tough, in which case it would be
preferred for its simplicity. Not? I'll add "Testing Gerhard's blog
API patch to my short term TODO list". Hopefully I get to it tonight
after work. Thanks Gerhard.
------------------------------------------------------------------------
May 12, 2004 - 20:12 : Kjartan
Good patch, just a few minor comments.
- Use single quotes for constant strings.
- I noticed some indentations that were off the 2 column, looks like
the are in the current code though.
- drupal_directory_ping() will only be invoked from xmlrpc.php so there
shouldn't be a need to include the file there.
------------------------------------------------------------------------
May 12, 2004 - 22:40 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc_2_0.patch (2.64 KB)
Updated. Don't know to which spaces you are referring. Guess Drupal CVS
needs to be code checked again.
------------------------------------------------------------------------
August 4, 2004 - 01:39 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmlrpc_3.patch (2.81 KB)
Updated again. It appears that parts of the old patch made it into
drupal.module, but the include statement was still in common.inc.
------------------------------------------------------------------------
August 4, 2004 - 05:47 : TDobes
+1... I tested the patch with blogapi.module and w.bloggar and it works
fine, as far as I can tell. I like any patch that includes less code on
each page view.
------------------------------------------------------------------------
August 4, 2004 - 20:36 : Dries
Committed to HEAD. Thanks.
------------------------------------------------------------------------
August 13, 2004 - 18:47 : walkah
Attachment: http://drupal.org/files/issues/xmlrpc-include.diff (2.38 KB)
this patch didn't break blogapi.module, it's true. but it _did_ break
drupal.module's distributed authentication feature. the problem is that
xmlrpc.inc declares some classes, which will not work if the include
statement appears inside a function. see the following for more
details:
http://us4.php.net/manual/en/language.functions.php (specifically the
comment by albaity at php4web dot com)
the attached patch restores the drupal.module functionality (as well as
reintroduces the include in common.inc).
I'm afraid that's just the way it has to be, sorry killes ;)
(this patch also fixes a typo in drupal.module where the 'name' array
key was not quoted - which may break things under higher error
reporting levels).
------------------------------------------------------------------------
August 13, 2004 - 19:23 : Anonymous
Can't you include common.inc from drupal.module if it needs that file?
locale.module also includes its locale.inc without punishing the user
who doesn't care about its functionality.
Gerhard
------------------------------------------------------------------------
August 14, 2004 - 06:29 : Dries
Including the XML-RPC library at the top of those files/modules that
need it sounds like a fair alternative.
------------------------------------------------------------------------
August 14, 2004 - 11:19 : Steven
But that doesn't really help unless you have no XML-RPC modules enabled
at all...
------------------------------------------------------------------------
August 14, 2004 - 12:58 : JonBob
What is more, I don't think it even fixes the bug.
The problem is that class declarations in PHP4 are not guaranteed to
work correctly when made inside a function. This applies to
declarations immediately inside a function definition, or in files
included from inside a function definition, or even from files included
from files included from function definitions. Note that since module
files are included from module_load(), this means class definitions or
includes of files that have them cannot safely be in modules.
Basically, conditional inclusion of classes is a no-no. To get around
this we'd have to rewrite xmlrpc.inc using functions rather than object
methods.
------------------------------------------------------------------------
August 16, 2004 - 18:29 : Dries
I reverted the patch.
------------------------------------------------------------------------
August 17, 2004 - 15:39 : walkah
ya, but you forgot to put the include_once back in common.inc . :)
------------------------------------------------------------------------
August 17, 2004 - 17:59 : killes at www.drop.org
Can't just somebody step forward and rewrite that class in functions?
------------------------------------------------------------------------
August 31, 2004 - 21:41 : killes at www.drop.org
I'd like to keep this open. It is so nicely assigned. ;->
------------------------------------------------------------------------
September 1, 2004 - 12:35 : Anonymous
*grumble*
------------------------------------------------------------------------
January 31, 2005 - 23:05 : killes at www.drop.org
Attachment: http://drupal.org/files/issues/xmplrpc.patch (695 bytes)
Here is an alternative approach. XML-RPC requests are suppoed to be
POST requests, not GET. By jvandyk and myself.
--
View: http://drupal.org/node/7458
Edit: http://drupal.org/project/comments/add/7458
More information about the drupal-devel
mailing list