From 5abd2b7d0c5565ee842969cd5205c9b428efbb6c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 22 Dec 2010 11:06:45 -0800 Subject: [PATCH 1/2] fix notice error --- actions/backupaccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/backupaccount.php b/actions/backupaccount.php index 9454741f00..4f6fb936bd 100644 --- a/actions/backupaccount.php +++ b/actions/backupaccount.php @@ -97,7 +97,7 @@ class BackupaccountAction extends Action function handle($argarray=null) { - parent::handle($args); + parent::handle($argarray); if ($this->isPost()) { $this->sendFeed(); From 754bc1b6164b82109acd14d70b295291f40d07c7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 22 Dec 2010 11:13:57 -0800 Subject: [PATCH 2/2] Error handling cleanup on backup/restore: * avoid PHP notice from using wrong variable * show a visible error instead of blank screen if no file submitted with restore form * avoid PHP strict warning from using calling "non-static" DOMDocument::loadXML statically * suppress PHP warning from XML parse errors --- actions/restoreaccount.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/actions/restoreaccount.php b/actions/restoreaccount.php index c33756d48f..5c8e4a12c1 100644 --- a/actions/restoreaccount.php +++ b/actions/restoreaccount.php @@ -95,7 +95,7 @@ class RestoreaccountAction extends Action function handle($argarray=null) { - parent::handle($args); + parent::handle($argarray); if ($this->isPost()) { $this->restoreAccount(); @@ -143,6 +143,7 @@ class RestoreaccountAction extends Action return; case UPLOAD_ERR_NO_FILE: // No file; probably just a non-AJAX submission. + throw new ClientException(_('No uploaded file.')); return; case UPLOAD_ERR_NO_TMP_DIR: // TRANS: Client exception thrown when a temporary folder is not present to store a file upload. @@ -185,12 +186,19 @@ class RestoreaccountAction extends Action // This check is costly but we should probably give // the user some info ahead of time. + $doc = new DOMDocument(); - $doc = DOMDocument::loadXML($xml); + // Disable PHP warnings so we don't spew low-level XML errors to output... + // would be nice if we can just get exceptions instead. + $old_err = error_reporting(); + error_reporting($old_err & ~E_WARNING); + $doc->loadXML($xml); + error_reporting($old_err); $feed = $doc->documentElement; - if ($feed->namespaceURI != Activity::ATOM || + if (!$feed || + $feed->namespaceURI != Activity::ATOM || $feed->localName != 'feed') { throw new ClientException(_("Not an atom feed.")); }