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:
Mikael Nordfeldth
2013-09-24 01:17:04 +02:00
parent 1744fec89f
commit 1c6f9df80e
23 changed files with 50 additions and 102 deletions

View 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();
}
}

View 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;
}

View 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);
}