]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
PHP5.5 fix: Better use of startXML for Action classes (mostly AJAX)
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 23 Sep 2013 23:17:04 +0000 (01:17 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 23 Sep 2013 23:18:33 +0000 (01:18 +0200)
I had a problem with PHP5.5 that caused ajax responses to be empty. This
fixes it, as the problem was related to pretty inconsistent calling to
headers, XMLWriter::startDocument etc. etc.

23 files changed:
actions/conversationreplies.php
actions/newmessage.php
actions/newnotice.php
actions/shownotice.php
lib/atom10feed.php
lib/htmloutputter.php
plugins/Blog/actions/newblogentry.php
plugins/Bookmark/actions/newbookmark.php
plugins/Event/actions/cancelrsvp.php
plugins/Event/actions/newevent.php
plugins/Event/actions/newrsvp.php
plugins/MobileProfile/MobileProfilePlugin.php
plugins/OStatus/actions/ostatusinit.php
plugins/OStatus/actions/ostatussub.php
plugins/Poll/actions/newpoll.php
plugins/Poll/actions/respondpoll.php
plugins/QnA/actions/qnaclosequestion.php
plugins/QnA/actions/qnanewanswer.php
plugins/QnA/actions/qnanewquestion.php
plugins/QnA/actions/qnareviseanswer.php
plugins/QnA/actions/qnavote.php
plugins/UserFlag/actions/clearflag.php
plugins/UserFlag/actions/flagprofile.php

index 55c3efa9e0cb6eb63099b23885d608a816733531..49c806fa98588a00ccf3569a528830806e1c11f8 100644 (file)
@@ -73,9 +73,7 @@ class ConversationRepliesAction extends ConversationAction
 
     function showAjax()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for conversation page.
         $this->element('title', null, _m('TITLE','Notice'));
@@ -83,6 +81,6 @@ class ConversationRepliesAction extends ConversationAction
         $this->elementStart('body');
         $this->showContent();
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 }
index b1b1c1db062ef574193a3995f4c77adfbf61d693..6816ffae6bfc76a31d561d95cc79fadaae671ccd 100644 (file)
@@ -194,9 +194,7 @@ class NewmessageAction extends FormAction
 
         $this->msg = $msg;
         if ($this->trimmed('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title on page for sending a direct message.
             $this->element('title', null, _('New message'));
index 1c8f956b5d80bef41bf40916ab6347149608a451..749cfdecb36e4f764d90f456e05d3558bacbd8f2 100644 (file)
@@ -174,9 +174,7 @@ class NewnoticeAction extends FormAction
         Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
 
         if (StatusNet::isAjax()) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _('Notice posted'));
@@ -184,7 +182,7 @@ class NewnoticeAction extends FormAction
             $this->elementStart('body');
             $this->showNotice($notice);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
             exit;
         } else {
             $returnto = $this->trimmed('returnto');
index d892e51409fd72adad2be93a3b7c9448a40e559d..3b3e50884ddf5c35f734559400904ef920cf9628 100644 (file)
@@ -250,9 +250,7 @@ class ShownoticeAction extends Action
 
     function showAjax()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for page that shows a notice.
         $this->element('title', null, _m('TITLE','Notice'));
@@ -261,7 +259,7 @@ class ShownoticeAction extends Action
         $nli = new NoticeListItem($this->notice, $this);
         $nli->show();
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 
     /**
index d5faafa1b3756d96ab20bc233a6bb47e2d182295..2d617326c5dded37223842255d5a939b2ef82927 100644 (file)
@@ -167,7 +167,7 @@ class Atom10Feed extends XMLStringer
 
     function initFeed()
     {
-        $this->xw->startDocument('1.0', 'UTF-8');
+        $this->startXML();
         $commonAttrs = array('xml:lang' => 'en-US');
         foreach ($this->namespaces as $prefix => $uri) {
             if ($prefix == '') {
index 9a43ef069efaae237df31f7b48931827ec1103ee..578518ea411a7ae219500d3439e4fd1835379276 100644 (file)
@@ -118,7 +118,7 @@ class HTMLOutputter extends XMLOutputter
         $this->extraHeaders();
         if (preg_match("/.*\/.*xml/", $type)) {
             // Required for XML documents
-            $this->xw->startDocument('1.0', 'UTF-8');
+            $this->startXML();
         }
         $this->xw->writeDTD('html',
                             '-//W3C//DTD XHTML 1.0 Strict//EN',
index d6421abea28f281675e00f62a2bb3020e3c82676..99fc89f2fb136fe71319f6e2e01d395857d15a53 100644 (file)
@@ -120,9 +120,7 @@ class NewblogentryAction extends Action
                                     $options);
         
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml; charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Blog entry saved'));
@@ -131,7 +129,7 @@ class NewblogentryAction extends Action
             $nli = new NoticeListItem($saved, $this);
             $nli->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
index 57be783b3805003ad8d4ba8941ded6ae75bc77c2..1c7dd5bc62f6d6444f102bff1368e5d30ab6aeb3 100644 (file)
@@ -150,9 +150,7 @@ class NewbookmarkAction extends Action
 
         } catch (ClientException $ce) {
             if ($this->boolean('ajax')) {
-                header('Content-Type: text/xml;charset=utf-8');
-                $this->xw->startDocument('1.0', 'UTF-8');
-                $this->elementStart('html');
+                $this->startHTML('text/xml;charset=utf-8');
                 $this->elementStart('head');
                 // TRANS: Page title after an AJAX error occurs
                 $this->element('title', null, _('Ajax Error'));
@@ -160,7 +158,7 @@ class NewbookmarkAction extends Action
                 $this->elementStart('body');
                 $this->element('p', array('id' => 'error'), $ce->getMessage());
                 $this->elementEnd('body');
-                $this->elementEnd('html');
+                $this->endHTML();
                 return;
             } else {
                 $this->error = $ce->getMessage();
@@ -170,9 +168,7 @@ class NewbookmarkAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after posting a bookmark.
             $this->element('title', null, _m('Bookmark posted'));
@@ -180,7 +176,7 @@ class NewbookmarkAction extends Action
             $this->elementStart('body');
             $this->showNotice($saved);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
index ab6cc5037e5d91943ce713f79be42ee52dc72456..1a30e86a1e8e87eb0d51ef380f2895d5b094ff2c 100644 (file)
@@ -150,20 +150,16 @@ class CancelrsvpAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Event saved'));
             $this->elementEnd('head');
             $this->elementStart('body');
-            $this->elementStart('body');
             $form = new RSVPForm($this->event, $this);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         }
     }
 
index 4c2157e01eebbe7b63843e820959618300713ade..cd2649060251825152a2e18b721cd2ad210c1e44 100644 (file)
@@ -244,9 +244,7 @@ class NeweventAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Event saved'));
@@ -254,7 +252,7 @@ class NeweventAction extends Action
             $this->elementStart('body');
             $this->showNotice($saved);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
@@ -263,9 +261,7 @@ class NeweventAction extends Action
     // @todo factor this out into a base class
     function outputAjaxError($msg)
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title after an AJAX error occurs
         $this->element('title', null, _('Ajax Error'));
@@ -273,7 +269,7 @@ class NeweventAction extends Action
         $this->elementStart('body');
         $this->element('p', array('id' => 'error'), $msg);
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
         return;
     }
 
index 272c6f0d9f624b5fed798f22bafa047d2a16e491..cbe67ae1733cac3456e21e6db6f6896b7e03df4f 100644 (file)
@@ -155,20 +155,16 @@ class NewrsvpAction extends Action
 
         if ($this->boolean('ajax')) {
             $rsvp = RSVP::fromNotice($saved);
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after creating an event.
             $this->element('title', null, _m('Event saved'));
             $this->elementEnd('head');
             $this->elementStart('body');
-            $this->elementStart('body');
             $cancel = new CancelRSVPForm($rsvp, $this);
             $cancel->show();
             $this->elementEnd('body');
-            $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
index 0eb57035d1290155db75a2d90d11fd857ba5d372..6e682a4f87c70bd0975c25a4541e8ff9a93a8e45 100644 (file)
@@ -209,7 +209,7 @@ class MobileProfilePlugin extends WAP20Plugin
            $action->extraHeaders();
            if (preg_match("/.*\/.*xml/", $type)) {
                // Required for XML documents
-               $action->xw->startDocument('1.0', 'UTF-8');
+               $action->startXML();
            }
            $action->xw->writeDTD('html',
                            '-//WAPFORUM//DTD XHTML Mobile 1.0//EN',
index c7c8baa5265b1ad4327cf541b1d80e0d6d633a65..f559eec3e321f7542f957caadd6941c1b2269c6b 100644 (file)
@@ -80,9 +80,7 @@ class OStatusInitAction extends Action
     {
         $this->err = $err;
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Form title.
             $this->element('title', null, _m('TITLE','Subscribe to user'));
@@ -90,7 +88,7 @@ class OStatusInitAction extends Action
             $this->elementStart('body');
             $this->showContent();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             $this->showPage();
         }
index 59bd6761cab4cb101154da0526ca92f41e6db335..f27c3658b17683cb3284f233e7823fd1a7f7b9b8 100644 (file)
@@ -373,9 +373,7 @@ class OStatusSubAction extends Action
             $this->error = $err;
         }
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Form title.
             $this->element('title', null, _m('Subscribe to user'));
@@ -383,7 +381,7 @@ class OStatusSubAction extends Action
             $this->elementStart('body');
             $this->showContent();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             $this->showPage();
         }
index e7d5d3dd0d6d32484d7b9cb9e4f83cada24bb1c0..ed73140e2f680767955fff2e0c0a242ee66b3f3f 100644 (file)
@@ -158,9 +158,7 @@ class NewPollAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Notice posted'));
@@ -168,7 +166,7 @@ class NewPollAction extends Action
             $this->elementStart('body');
             $this->showNotice($saved);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
index df3f68e87c63511f6f94b7a4e9d223eaf37dd7d3..8de929241741f342226570d5d3c0cedabc1cfc1e 100644 (file)
@@ -144,9 +144,7 @@ class RespondPollAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a poll response.
             $this->element('title', null, _m('Poll results'));
@@ -155,7 +153,7 @@ class RespondPollAction extends Action
             $form = new PollResultForm($this->poll, $this);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($this->poll->bestUrl(), 303);
         }
index 87a848987ceb3d36438a5e08d2abb79f1dc1a551..9a72b218093d6894139d92aebffb0ba355130b65 100644 (file)
@@ -147,9 +147,7 @@ class QnaclosequestionAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending an answer.
             $this->element('title', null, _m('Answers'));
@@ -158,7 +156,7 @@ class QnaclosequestionAction extends Action
             $form = new QnashowquestionForm($this, $this->question);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($this->question->bestUrl(), 303);
         }
index 661cbcc328a9dae4a103e9e1d46bf8cdb815545c..92b640c1669ea5e3026cca31d1c0ad182da48959 100644 (file)
@@ -151,10 +151,8 @@ class QnanewanswerAction extends Action
         if ($this->boolean('ajax')) {
             common_debug("ajaxy part");
             $answer = $this->question->getAnswer($profile);
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
 
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending an answer.
             $this->element('title', null, _m('Answers'));
@@ -166,7 +164,7 @@ class QnanewanswerAction extends Action
             $nli->show();
 
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_debug("not ajax");
             common_redirect($this->question->bestUrl(), 303);
index d6584b8f44a637d66dc76b70528a2679854ea1eb..9fc05e7818836ae643f6d6a3bce4fd94aeb056a1 100644 (file)
@@ -148,9 +148,7 @@ class QnanewquestionAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Question posted'));
@@ -158,7 +156,7 @@ class QnanewquestionAction extends Action
             $this->elementStart('body');
             $this->showNotice($saved);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($saved->bestUrl(), 303);
         }
index 707a81f8ac6b21c29f05c4d4ebc7c462a6ef8a0a..c08edb2cc3a7429a9e02ab4404fb9e780a90cfce 100644 (file)
@@ -155,9 +155,7 @@ class QnareviseanswerAction extends Action
         }
         if ($this->boolean('ajax')) {
             common_debug("ajaxy part");
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending an answer.
             $this->element('title', null, _m('Answer'));
@@ -166,7 +164,7 @@ class QnareviseanswerAction extends Action
             $form = new QnashowanswerForm($this, $answer);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($this->answer->bestUrl(), 303);
         }
@@ -199,9 +197,7 @@ class QnareviseanswerAction extends Action
         }
         if ($this->boolean('ajax')) {
             common_debug("ajaxy part");
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending an answer.
             $this->element('title', null, _m('Answer'));
@@ -210,7 +206,7 @@ class QnareviseanswerAction extends Action
             $form = new QnashowanswerForm($this, $answer);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($this->answer->bestUrl(), 303);
         }
@@ -239,9 +235,7 @@ class QnareviseanswerAction extends Action
 
     function showAjaxReviseForm()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Form title for sending an answer.
         $this->element('title', null, _m('TITLE','Answer'));
@@ -250,7 +244,7 @@ class QnareviseanswerAction extends Action
         $form = new QnareviseanswerForm($this->answer, $this);
         $form->show();
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 
     /**
index df4898dfe9806fa7bdaf61c31c6703e66494cf0b..5e227a69ceada7edf48c6efec8576336bd0b4e59 100644 (file)
@@ -142,9 +142,7 @@ class Qnavote extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending in a vote for a question or answer.
             $this->element('title', null, _m('Answers'));
@@ -153,7 +151,7 @@ class Qnavote extends Action
             $form = new QnA_Answer($this->question, $this);
             $form->show();
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             common_redirect($this->question->bestUrl(), 303);
         }
index e5704d6af5475a72b8f4a7154cc4b7ce72ab86bd..c2443d6d58e76521199b1da01595b3d70a8bff36 100644 (file)
@@ -121,9 +121,7 @@ class ClearflagAction extends ProfileFormAction
      */
     function ajaxResults()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for AJAX form to indicated that flags were removed.
         $this->element('title', null, _m('Flags cleared'));
@@ -132,6 +130,6 @@ class ClearflagAction extends ProfileFormAction
         // TRANS: Body element for "flags cleared" form.
         $this->element('p', 'cleared', _m('Cleared'));
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 }
index 7096d3748e4cb9fd3cfe2edab43264799d71e6a2..4c4dc46f60ffcb044a3a7e6e932fa7b6ea3df7fd 100644 (file)
@@ -117,9 +117,7 @@ class FlagprofileAction extends ProfileFormAction
      */
     function ajaxResults()
     {
-        header('Content-Type: text/xml;charset=utf-8');
-        $this->xw->startDocument('1.0', 'UTF-8');
-        $this->elementStart('html');
+        $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: AJAX form title for a flagged profile.
         $this->element('title', null, _m('Flagged for review'));
@@ -128,6 +126,6 @@ class FlagprofileAction extends ProfileFormAction
         // TRANS: Body text for AJAX form when a profile has been flagged for review.
         $this->element('p', 'flagged', _m('Flagged'));
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 }