PHP5.5 fix: Better use of startXML for Action classes (mostly AJAX)
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.
This commit is contained in:
parent
1744fec89f
commit
1c6f9df80e
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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'));
|
||||
|
@ -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');
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 == '') {
|
||||
|
@ -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',
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user