Update docs - in particular add one (incomplete) file describing all API changes...
authorgggeek <giunta.gaetano@gmail.com>
Mon, 25 May 2015 19:14:08 +0000 (20:14 +0100)
committergggeek <giunta.gaetano@gmail.com>
Mon, 25 May 2015 19:14:08 +0000 (20:14 +0100)
INSTALL.md
NEWS
README.md
doc/api_changes_v4.md [new file with mode: 0644]

index 8d77e7c..f78f8f0 100644 (file)
@@ -1,4 +1,5 @@
 XMLRPC for PHP
+==============
 
 Requirements
 ------------
@@ -79,7 +80,9 @@ Installation of the library is quite easy:
         as leaving it open to access means that any visitor can trigger execution of php code such as
         the built-in debugger.
 
+Tips
+----
 
-Please note that usage of the 'make' command for installation of the library is
-not recommended, as it will generally involve editing of the makefile for a
-successful run.
+Please note that usage of the 'pake' command is not required for installation of the library.
+At this moment it is only useful to build the html and pdf versions of the documentation, and the tarballs
+for distribution of the library.
diff --git a/NEWS b/NEWS
index bba59f7..0a3a9a3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,27 +10,31 @@ more recent versions.
 
 PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade.
 
-* new: introduction of namespaces.
+* new: introduction of namespaces and full OOP.
 
   All php classes have been renamed and moved to separate files.
   Class autoloading can now be done in accord with the PSR-4 standard.
+  All global variables and global functions have been removed.
+
   Backward compatibility is maintained via lib/xmlrpc.inc, lib/xmlrpcs.inc and lib/xmlrpc_wrappers.inc.
   For more details, head on to doc/api_changes_v4.md
 
 * changed: the default encoding delivered from the library to your code is now utf8.
   It can be changed at anytime setting a value to PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding
 
-* improved: all php code is now formatted according to the PSR-2 standard
-
 * improved: no need to call anymore $client->setSSLVerifyHost(2) to silence a curl warning when using https
   with recent curl builds
 
-* improved: debug messages are not html-escaped any more when executing from the command line
-
 * improved: a specific option allows users to decide the version of SSL to use for https calls.
   This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
   and the cURL extension has been compiled with GnuTLS (such as on Travis VMs)
 
+* improved: the function wrap_php_function() now can be used to wrap closures (it is now a method btw)
+
+* improved: all wrap_something() functions now return a closure by default instead of a function name
+
+* improved: debug messages are not html-escaped any more when executing from the command line
+
 * improved: the library is now tested using Travis ( https://travis-ci.org/ ).
   Tests are executed using all php versions from 5.3 to 7.0 nightly, plus HHVM; code-coverage information
   is generated using php 5.6 and uploaded to both Code Coverage and Scrutinizer online services
@@ -39,11 +43,15 @@ PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade.
 
 * improved: when phpunit is used to generate code-coverage data, the code executed server-side is accounted for
 
-* improved: the testsuite has basic checks for the debugger and demo files
+* improved: the test suite has basic checks for the debugger and demo files
+
+* improved: more tests in the test suite
 
-* fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml prolog only
+* fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml
+  prolog only
 
-* fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml prolog only
+* fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml
+  prolog only
 
 * fixed: the function decode_xml() would not decode an xml with character set declaration in the xml prolog
 
@@ -54,8 +62,8 @@ PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade.
 
 * improved: the debugger is displayed using UTF-8, making it more useful to debug any kind of service
 
-* improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding
-  (this is visible e.g. in the debugger)
+* improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding;
+  previously those messages would just disappear (this is visible e.g. in the debugger)
 
 * changed: debug info handling
     - at debug level 1, the rebuilt php objects are not dumped to screen (server-side already did that)
@@ -64,13 +72,20 @@ PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade.
 
 * improved: makefiles have been replaced with a php_based pakefile
 
+* improved: the source for the manual is stored in asciidoc format, which can be displayed natively by GitHub
+  with nice html formatting. Also the HTML version generated by hand and bundled in tarballs is much nicer
+  to look at than previous versions
+
+* improved: all php code is now formatted according to the PSR-2 standard
+
 
 XML-RPC for PHP version 3.0.0 - 2014/6/15
 
 This release corrects all bugs that have been reported and successfully reproduced since
 version 3.0.0 beta.
 
-The requirements have increased to php 5.1.0 - which is still way older than what you should be running for any serious purpose, really.
+The requirements have increased to php 5.1.0 - which is still way older than what you should be running for any serious
+purpose, really.
 
 It also is the first release to be installable via composer.
 
@@ -87,15 +102,19 @@ The "beta" tag is meant to indicate the fact that the refactoring has been more
 than in precedent releases and that more changes are likely to be introduced with time -
 the library is still considered to be production quality.
 
-* improved: removed all usage of php functions deprecated in php 5.3, usage of assign-by-ref when creating new objects etc...
+* improved: removed all usage of php functions deprecated in php 5.3, usage of assign-by-ref when creating new objects
+  etc...
 * improved: add support for the <ex:nil/> tag used by the apache library, both in input and output
 * improved: add support for dateTime objects in both in php_xmlrpc_encode and as parameter for constructor of xmlrpcval
 * improved: add support for timestamps as parameter for constructor of xmlrpcval
 * improved: add option 'dates_as_objects' to php_xmlrpc_decode to return dateTime objects for xmlrpc datetimes
-* improved: add new method SetCurlOptions to xmrlpc_client to allow extra flexibility in tweaking http config, such as explicitly binding to an ip address
+* improved: add new method SetCurlOptions to xmrlpc_client to allow extra flexibility in tweaking http config, such as
+  explicitly binding to an ip address
 * improved: add new method SetUserAgent to xmrlpc_client to to allow having different user-agent http headers
-* improved: add a new member variable in server class to allow fine-tuning of the encoding of returned values when the server is in 'phpvals' mode
-* improved: allow servers in 'xmlrpcvals' mode to also register plain php functions by defining them in the dispatch map with an added option
+* improved: add a new member variable in server class to allow fine-tuning of the encoding of returned values when the
+  server is in 'phpvals' mode
+* improved: allow servers in 'xmlrpcvals' mode to also register plain php functions by defining them in the dispatch map
+  with an added option
 * improved: catch exceptions thrown during execution of php functions exposed as methods by the server
 * fixed: bad encoding if same object is encoded twice using php_xmlrpc_encode
 
@@ -110,13 +129,16 @@ support that ancient, broken and insecure platform.
 
 * fixed: php warning when receiving 'false' in a bool value
 * fixed: improve robustness of the debugger when parsing weird results from non-compliant servers
-* fixed: format floating point values using the correct decimal separator even when php locale is set to one that uses comma
-* fixed: use feof() to test if socket connections are to be closed instead of the number of bytes read (rare bug when communicating with some servers)
+* fixed: format floating point values using the correct decimal separator even when php locale is set to one that uses
+  comma
+* fixed: use feof() to test if socket connections are to be closed instead of the number of bytes read (rare bug when
+  communicating with some servers)
 * fixed: be more tolerant in detection of charset in http headers
 * fixed: fix encoding of UTF8 chars outside of the BMP plane
 * fixed: fix detection of zlib.output_compression
 * improved: allow the add_to_map server method to add docs for single params too
-* improved: added the possibility to wrap for exposure as xmlrpc methods plain php class methods, object methods and even whole classes
+* improved: added the possibility to wrap for exposure as xmlrpc methods plain php class methods, object methods and
+  even whole classes
 
 
 XML-RPC for PHP version 2.2.1 - 2008/03/06
index a75235b..78d216d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,6 +14,10 @@ The user manual can be found in the doc/manual directory, in Asciidoc format: [p
 
 Release tarballs also contain the HTML and PDF versions, as well as an automatically generated API documentation.
 
+Upgrading
+---------
+If you are upgrading from version 3 or earlier, please read the docs in [doc/api_changes_v4.md](doc/api_changes_v4.md)
+
 License
 -------
 Use of this software is subject to the terms in the [license.txt](license.txt) file
diff --git a/doc/api_changes_v4.md b/doc/api_changes_v4.md
new file mode 100644 (file)
index 0000000..ff462e5
--- /dev/null
@@ -0,0 +1,204 @@
+API Changes between library versions 3 and 4
+============================================
+
+Class loading
+-------------
+
+It is not necessary any more to include the files xmlrpc.inc, xmlrpcs.inc and xmlrpc_wrappers.inc to have the
+library classes available.
+
+Instead, it is recommended to rely on class autoloading.
+* If you are using Composer, just install the library by declaring it as dependency for your project in composer.json 
+
+        "require": {
+            ...,
+            "phpxmlrpc/phpxmlrpc": "~4.0"
+        },
+       
+* If you do not use Composer, an autoloader for the library can be found in src/Atuloader.php.
+  The php example files in the demo/client folder do make use of it.
+  Example code to set up the autoloader:
+    
+        include_once <path to library> . "/src/Autoloader.php";
+        PhpXmlRpc\Autoloader::register();
+
+
+* If you still include manually xmlrpc.inc, xmlrpcs.inc or xmlrpc_wrappers.inc, you will not need to set up
+  class autoloading, as those files do include all the source files for the library classes
+
+
+New class naming
+----------------
+
+All classes have ben renamed, are now properly namespaced and follow the CamelCase naming convention.
+Existing class methods and members have been preserved; all new method names follow camelCase. 
+
+Conversion table:
+
+| Old class     | New class          |
+| ------------- | ------------------ |
+| xmlrpc_client | PhpXmlRpc\Client   |
+| xmlrpc_server | PhpXmlRpc\Server   |
+| xmlrpcmsg     | PhpXmlRpc\Request  |
+| xmlrpcresp    | PhpXmlRpc\Response |
+| xmlrpcval     | PhpXmlRpc\Value    |
+
+
+Global variables cleanup
+------------------------
+
+All variables in the global scope have been moved into classes.
+
+Conversion table:
+
+| Old variable             | New variable                                | Notes     |
+| ------------------------ | ------------------------------------------- | --------- |
+| _xmlrpcs_capabilities    | NOT AVAILABLE YET                           |           |
+| _xmlrpc_debuginfo        | PhpXmlRpc\Server::$_xmlrpc_debuginfo        | protected |
+| _xmlrpcs_dmap            | NOT AVAILABLE YET                           |           |
+| _xmlrpcs_occurred_errors | PhpXmlRpc\Server::$_xmlrpcs_occurred_errors | protected |
+| _xmlrpcs_prev_ehandler   | PhpXmlRpc\Server::$_xmlrpcs_prev_ehandler   | protected |
+| xmlrpcWPFObjHolder       | PhpXmlRpc\Wrapper::$objHolder               |           |
+| ...                      |                                             |           |
+
+
+Global functions cleanup
+------------------------
+
+Most functions in the global scope have been moved into classes.
+
+| Old function             | New function                                |
+| ------------------------ | ------------------------------------------- |
+| ...                      |                                             |
+
+
+Character sets and encoding
+---------------------------
+
+The default character set used by the library to deliver data to your app is now UTF8.
+It is also the character set that the library expects data from your app to be in (including method names).
+The value can be changed (to either US-ASCII or ISO-8859-1) by setting teh desired value to
+    PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding
+
+Usage of closures for wrapping
+------------------------------
+
+...
+
+
+Differences in server behaviour
+-------------------------------
+
+The results for calls to system.listMethods and system.getCapabilities can not be set anymore via changes to
+global variables.
+
+
+Other
+-----
+
+* when serialize() is invoked on a response and its payload can not be serialized, an exception is thrown instead of
+  ending all execution
+
+* all error messages now mention the class and method which generated name
+
+* all library source code has been moved to the src/ directory 
+
+* all source code has been reformatted according to modern PSR standards
+
+
+Enabling compatibility with legacy code
+---------------------------------------
+
+If you have code which relies on version 3 of the phpxmlrpc API, you *should* be able to use version 4 as a drop-in
+replacement, regardless of all of the changes mentioned above.
+
+The magic happens via the xmlrpc.inc, xmlrpcs.inc and xmlrpc_wrappers.inc files, which have been kept solely for
+the purpose of backwards compatibility (you might notice that they are still in the 'lib' directory, whereas all of
+the refactored code now sits in the 'src' directory).
+
+Of course, some minor changes where inevitable, and backwards compatibility can not be guaranteed at 100%.
+Below is the list of all known changes and possible pitfalls.
+
+### Default character set used for application data
+
+* when including the xmlrpc.inc file, the defalt character set used by the lib to give data to your app gets switched
+  back to ISO-8859-1, as it was in previous versions
+
+* if yor app used to change that value, you will need to add one line to your code, to make sure it is properly used
+
+        // code as was before
+        include('xmlrpc.inc');
+        $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
+        // new line needed now
+        PhpXmlRpc\PhpXmlRpc::importGlobals();
+
+### Usage of global variables
+
+* ALL global variables which existed after including xmlrpc.inc in version 3 still do exist after including it in v. 4
+* Code which relies on using (as in 'reading') their value will keep working unchanged
+
+* Changing the value of some of those variables does not have any effect anymore on library operation.
+  This is true for:
+
+        $GLOBALS['xmlrpcI4']
+        $GLOBALS['xmlrpcInt']
+        $GLOBALS['xmlrpcBoolean']
+        $GLOBALS['xmlrpcDouble']
+        $GLOBALS['xmlrpcString']
+        $GLOBALS['xmlrpcDatetTme']
+        $GLOBALS['xmlrpcBase64']
+        $GLOBALS['xmlrpcArray']
+        $GLOBALS['xmlrpcStruct']
+        $GLOBALS['xmlrpcValue']
+        $GLOBALS['xmlrpcNull']
+        $GLOBALS['xmlrpcTypes']
+        $GLOBALS['xmlrpc_valid_parents']
+        $GLOBALS['xml_iso88591_Entities']
+
+* Changing the value of the other global variables will still have an effect on operation of the library, but only after
+  a call to PhpXmlRpc::importGlobals()
+
+    Example:
+
+        // code as was before
+        include('xmlrpc.inc');
+        $GLOBALS['xmlrpc_null_apache_encoding'] = true;
+        // new line needed now
+        PhpXmlRpc\PhpXmlRpc::importGlobals();
+        
+    Alternative solution:
+    
+        include('xmlrpc.inc');
+        PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_apache_encoding = true;
+
+* Not all variables which existed after including xmlrpcs.inc in version 3 are available
+
+    - $GLOBALS['_xmlrpcs_prev_ehandler'] has been replaced with protected static var PhpXmlRpc\Server::$_xmlrpcs_prev_ehandler
+        and is thus not available any more
+
+    - same for $GLOBALS['_xmlrpcs_occurred_errors']
+
+    - same for $GLOBALS['_xmlrpc_debuginfo']
+
+    - $GLOBALS['_xmlrpcs_capabilities'] and $GLOBALS['_xmlrpcs_dmap'] have been removed
+
+### Using typeof/class-name checks in your code
+
+* if you are checking the types of returned objects, your checks will most likely fail.
+  This is due to the fact that 'old' classes extend the 'new' versions, but library code that creates object
+  instances will return the new classes.
+
+    Example:
+        
+        is_a(php_xmlrpc_encode('hello world'), 'xmlrpcval') => false
+        is_a(php_xmlrpc_encode('hello world'), 'PhpXmlRpc\Value') => true
+
+### wrapping methods now return closures
+
+might be fixed later?
+
+### server behaviour can not be changed by setting global variables (the ones starting with _xmlrpcs_ )
+
+might be fixed later?