]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Suppress PHP warnings/notices during AtomPub XML parsing to avoid HTTP header problem...
authorBrion Vibber <brion@pobox.com>
Tue, 15 Mar 2011 17:09:20 +0000 (10:09 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 15 Mar 2011 17:11:13 +0000 (10:11 -0700)
If display_errors is on, typical settings would cause PHP error messages to spew to output before the HTTP headers for setting a 400 error go through.
Also switched from deprecated static DOMDocument::loadXML() to non-static call.

actions/apitimelineuser.php

index 66984b5abda1ca47ad8dafd338ca98c215d5237e..3fe73c691cf7bec1a329de3fa0f48297465d334d 100644 (file)
@@ -322,8 +322,11 @@ class ApiTimelineUserAction extends ApiBareAuthAction
             $this->clientError(_('Atom post must not be empty.'));
         }
 
-        $dom = DOMDocument::loadXML($xml);
-        if (!$dom) {
+        $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
+        $dom = new DOMDocument();
+        $ok = $dom->loadXML($xml);
+        error_reporting($old);
+        if (!$ok) {
             // TRANS: Client error displayed attempting to post an API that is not well-formed XML.
             $this->clientError(_('Atom post must be well-formed XML.'));
         }