facebook/hhvm — pull request #2991 by tstarling (2014-06-20 01:31:57+00:00)
Title: wddx_deserialize() systemlib improvements

* Use stream_get_contents() instead of a loop of fgets(). Loops that read files are deceptively tricky -- it's possible to hit an error in which fgets() permanently returns false but with feof() being false, for example NFS server failure, which would cause an infinite busy loop with the previous code.
* Do not accept SimpleXMLElement objects as input -- this was a hack to allow recursive parsing without creating another global function. Achieve the same ends using a closure instead.
* Do not attempt to call $packet->getName() on any input that is not a string or resource. Instead mimic Zend and give a warning.
* Check for errors from simplexml_load_string(), instead of giving a fatal error due to calling false->xpath().
* Ignore malformed input in various cases, skipping array members etc., instead of assuming the XML is always perfect and inevitably hitting a fatal error due to invalid method calls. This is somewhat similar to what Zend does -- probably not identical though.
* Added a test case for malformed input based on the motivating unit test from MediaWiki.