]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/restoreaccount.php
Merge branch 'master' of gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / actions / restoreaccount.php
index c33756d48ff90cf25dec76acea84e954baeee54f..8cf220a424f53b375c977de0231ece738bc10736 100644 (file)
@@ -48,6 +48,7 @@ if (!defined('STATUSNET')) {
 class RestoreaccountAction extends Action
 {
     private $success = false;
+    private $inprogress = false;
 
     /**
      * Returns the title of the page
@@ -95,7 +96,7 @@ class RestoreaccountAction extends Action
 
     function handle($argarray=null)
     {
-        parent::handle($args);
+        parent::handle($argarray);
 
         if ($this->isPost()) {
             $this->restoreAccount();
@@ -143,6 +144,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 +187,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."));
             }
@@ -200,8 +209,13 @@ class RestoreaccountAction extends Action
             $qm = QueueManager::get();
             $qm->enqueue(array(common_current_user(), $xml, false), 'feedimp');
 
-            $this->success = true;
-            
+            if ($qm instanceof UnQueueManager) {
+                // No active queuing means we've actually just completed the job!
+                $this->success = true;
+            } else {
+                // We've fed data into background queues, and it's probably still running.
+                $this->inprogress = true;
+            }
             $this->showPage();
 
         } catch (Exception $e) {
@@ -220,6 +234,9 @@ class RestoreaccountAction extends Action
     function showContent()
     {
         if ($this->success) {
+            $this->element('p', null,
+                           _('Feed has been restored. Your old posts should now appear in search and your profile page.'));
+        } else if ($this->inprogress) {
             $this->element('p', null,
                            _('Feed will be restored. Please wait a few minutes for results.'));
         } else {