]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Try to do intelligent redirect codes
authorEvan Prodromou <evan@controlyourself.ca>
Wed, 1 Apr 2009 19:30:59 +0000 (15:30 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Wed, 1 Apr 2009 19:32:30 +0000 (15:32 -0400)
After fixing the redirect code output, there are a lot of weirdnesses
with e.g. form handling. Try to add explicit redirect codes where
needed -- principly when handling a POST.

24 files changed:
actions/block.php
actions/deletenotice.php
actions/disfavor.php
actions/editgroup.php
actions/favor.php
actions/finishaddopenid.php
actions/finishopenidlogin.php
actions/finishremotesubscribe.php
actions/joingroup.php
actions/leavegroup.php
actions/login.php
actions/logout.php
actions/newgroup.php
actions/nudge.php
actions/remotesubscribe.php
actions/smssettings.php
actions/subedit.php
actions/subscribe.php
actions/tag.php
actions/tagother.php
actions/unblock.php
actions/unsubscribe.php
lib/openid.php
lib/settingsaction.php

index e77b634c86c962a3b3a92ac629051df1cd288110..34f991dc6126024451004e3115ad45c88106b1eb 100644 (file)
@@ -93,7 +93,8 @@ class BlockAction extends Action
             if ($this->arg('no')) {
                 $cur = common_current_user();
                 $other = Profile::staticGet('id', $this->arg('blockto'));
-                common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
+                common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)),
+                                303);
             } elseif ($this->arg('yes')) {
                 $this->blockProfile();
             } elseif ($this->arg('blockto')) {
@@ -102,7 +103,6 @@ class BlockAction extends Action
         }
     }
 
-
     function showContent() {
         $this->areYouSureForm();
     }
@@ -110,7 +110,7 @@ class BlockAction extends Action
     function title() {
         return _('Block user');
     }
-    
+
     function showNoticeForm() {
         // nop
     }
@@ -178,10 +178,11 @@ class BlockAction extends Action
         }
 
         if ($action) {
-            common_redirect(common_local_url($action, $args));
+            common_redirect(common_local_url($action, $args), 303);
         } else {
             common_redirect(common_local_url('subscriptions',
-                                             array('nickname' => $cur->nickname)));
+                                             array('nickname' => $cur->nickname)),
+                            303);
         }
     }
 }
index 16e2df8899ab0338a6dcf94fc626e72c6719fbbe..6c350b33ab36e3c45d278f5009f20d1259ef435c 100644 (file)
@@ -141,6 +141,6 @@ class DeletenoticeAction extends DeleteAction
             $url = common_local_url('public');
         }
 
-        common_redirect($url);
+        common_redirect($url, 303);
     }
 }
index 90bab3ccae86325c5005dcea10f4a89318f7e297..bc13b09da5ea931224a08cc07834034771167fd4 100644 (file)
@@ -49,7 +49,7 @@ class DisfavorAction extends Action
 {
     /**
      * Class handler.
-     * 
+     *
      * @param array $args query arguments
      *
      * @return void
@@ -100,7 +100,8 @@ class DisfavorAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('showfavorites',
-                                             array('nickname' => $user->nickname)));
+                                             array('nickname' => $user->nickname)),
+                            303);
         }
     }
 }
index e7e79040a4811622473f1296e52da72b90420bcc..39dad0465eb070ced615f205661e1115cb7f3b39 100644 (file)
@@ -166,7 +166,6 @@ class EditgroupAction extends Action
             return;
         }
 
-
         $nickname    = common_canonical_nickname($this->trimmed('nickname'));
         $fullname    = $this->trimmed('fullname');
         $homepage    = $this->trimmed('homepage');
@@ -221,7 +220,7 @@ class EditgroupAction extends Action
         if ($this->group->nickname != $orig->nickname) {
             common_redirect(common_local_url('editgroup',
                                              array('nickname' => $nickname)),
-                            307);
+                            303);
         } else {
             $this->showForm(_('Options saved.'));
         }
index 3940df6888c11a83ba2f26239766c7026b0d280a..3b7d979ebcc8139b67abaafb36904e0244629505 100644 (file)
@@ -52,7 +52,7 @@ class FavorAction extends Action
 {
     /**
      * Class handler.
-     * 
+     *
      * @param array $args query arguments
      *
      * @return void
@@ -100,13 +100,14 @@ class FavorAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('showfavorites',
-                                             array('nickname' => $user->nickname)));
+                                             array('nickname' => $user->nickname)),
+                            303);
         }
     }
 
     /**
      * Notifies a user when his notice is favorited.
-     * 
+     *
      * @param class $notice favorited notice
      * @param class $user   user declaring a favorite
      *
index 8f10505cffe1b3ac40fc70dbce97385af7bef774..32bceecfd547dac41e2036808d970c6fc3876f9c 100644 (file)
@@ -139,7 +139,7 @@ class FinishaddopenidAction extends Action
 
             oid_set_last($display);
 
-            common_redirect(common_local_url('openidsettings'));
+            common_redirect(common_local_url('openidsettings'), 303);
         }
     }
 
index 52d9be29c1e650d202dbf7d9c2645b6a7358f991..952185742f969656ae6b0de9b7bf36451d9e6fbd 100644 (file)
@@ -271,7 +271,8 @@ class FinishopenidloginAction extends Action
             common_rememberme($user);
         }
         unset($_SESSION['openid_rememberme']);
-        common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
+        common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
+                        303);
     }
 
     function connectUser()
@@ -324,7 +325,7 @@ class FinishopenidloginAction extends Action
                                     array('nickname' =>
                                           $nickname));
         }
-        common_redirect($url);
+        common_redirect($url, 303);
     }
 
     function bestNewNickname($display, $sreg)
index eaf57c2d8fac59ea5862d22b155de58eb1f45e55..d54c29a60365df22235bc0db9286a79b53becb00 100644 (file)
@@ -230,7 +230,8 @@ class FinishremotesubscribeAction extends Action
         # show up close to the top of the page
 
         common_redirect(common_local_url('subscribers', array('nickname' =>
-                                                             $user->nickname)));
+                                                             $user->nickname)),
+                        303);
     }
 
     function add_avatar($profile, $url)
index eeea4a37bfb1ed9b0233c8f74f8362aad24d94fe..a5d82ddc7780e3afeda2f38f9c16030773931fd1 100644 (file)
@@ -143,7 +143,8 @@ class JoingroupAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('groupmembers', array('nickname' =>
-                                                                   $this->group->nickname)));
+                                                                   $this->group->nickname)),
+                            303);
         }
     }
 }
\ No newline at end of file
index eb30d0e505977ca8e226230e171468b6bf714551..215ccd9017516f90a421dd6fe623a414709cf00b 100644 (file)
@@ -147,7 +147,8 @@ class LeavegroupAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('groupmembers', array('nickname' =>
-                                                                   $this->group->nickname)));
+                                                                   $this->group->nickname)),
+                            303);
         }
     }
 }
index b049791fb1858dac3d79625317efa0ae77bb5bd9..59c6b4874bc24464d6fd9fbc15f05128ad4da8f2 100644 (file)
@@ -138,7 +138,7 @@ class LoginAction extends Action
                                           $nickname));
         }
 
-        common_redirect($url);
+        common_redirect($url, 303);
     }
 
     /**
index 3977f90a032f2b6bd9167e8f5e410ce10e8ea2a3..b7681be3827ed25fe2546f7b83c8f7ea37fe9499 100644 (file)
@@ -46,10 +46,10 @@ require_once INSTALLDIR.'/lib/openid.php';
  */
 class LogoutAction extends Action
 {
-    
+
     /**
      * This is read only.
-     * 
+     *
      * @return boolean true
      */
     function isReadOnly()
@@ -59,7 +59,7 @@ class LogoutAction extends Action
 
     /**
      * Class handler.
-     * 
+     *
      * @param array $args array of arguments
      *
      * @return nothing
@@ -73,7 +73,7 @@ class LogoutAction extends Action
             common_set_user(null);
             common_real_login(false); // not logged in
             common_forgetme(); // don't log back in!
-            common_redirect(common_local_url('public'));
+            common_redirect(common_local_url('public'), 303);
         }
     }
 }
index cbd8dfeec53ff46fc10ceddccbee5a1cc0825418..67cd6b2f18005f3efc3878a71bec65cbe92a5365 100644 (file)
@@ -193,7 +193,7 @@ class NewgroupAction extends Action
 
         $group->query('COMMIT');
 
-        common_redirect($group->homeUrl(), 307);
+        common_redirect($group->homeUrl(), 303);
     }
 
     function nicknameExists($nickname)
index bc3d484788c433d951f85fb24f18079d4e966d8d..b4e5e01dd88d4ec4d5965ba531d5beca5dab246b 100644 (file)
@@ -50,7 +50,7 @@ class NudgeAction extends Action
 {
      /**
      * Class handler.
-     * 
+     *
      * @param array $args array of arguments
      *
      * @return nothing
@@ -75,7 +75,7 @@ class NudgeAction extends Action
 
         // CSRF protection
         $token = $this->trimmed('token');
-        
+
         if (!$token || $token != common_session_token()) {
             $this->clientError(_('There was a problem with your session token. Try again, please.'));
             return;
@@ -100,7 +100,8 @@ class NudgeAction extends Action
         } else {
             // display a confirmation to the user
             common_redirect(common_local_url('showstream',
-                                             array('nickname' => $other->nickname)));
+                                             array('nickname' => $other->nickname)),
+                            303);
         }
     }
 
index af130f42588057ba1b2a811352f1ebbef5f9d59c..2e721a38b01f7c3d70f0c2270bed534db17480e5 100644 (file)
@@ -99,7 +99,7 @@ class RemotesubscribeAction extends Action
         $this->elementStart('fieldset');
         $this->element('legend', 'Subscribe to a remote user');
         $this->hidden('token', common_session_token());
-        
+
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         $this->input('nickname', _('User nickname'), $this->nickname,
@@ -407,7 +407,7 @@ class RemotesubscribeAction extends Action
 
         # Redirect to authorization service
 
-        common_redirect($req->to_url());
+        common_redirect($req->to_url(), 303);
         return;
     }
 }
index a5f75d266c38e75577f6eb16df4fff4af13c8d6d..922bab9a4e3bc2ccec5bd15ad9df102d19e376ff 100644 (file)
@@ -488,7 +488,8 @@ class SmssettingsAction extends ConnectSettingsAction
         }
 
         common_redirect(common_local_url('confirmaddress',
-                                         array('code' => $code)));
+                                         array('code' => $code)),
+                        303);
     }
 
     /**
index 89081ffc76984eb7da9a8f51d941ccbc9bfd1b43..8ca2d791465ce34ce9e067051c18df0f1682321f 100644 (file)
@@ -85,7 +85,8 @@ class SubeditAction extends Action
             }
 
             common_redirect(common_local_url('subscriptions',
-                                             array('nickname' => $cur->nickname)));
+                                             array('nickname' => $cur->nickname)),
+                            303);
         }
     }
 }
index f761992de40f6fd7401f77ebae0a5b024642a20d..0bc522867e39ca4a62ffd12a5ebf417a85441ba5 100644 (file)
@@ -75,7 +75,8 @@ class SubscribeAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('subscriptions', array('nickname' =>
-                                                                $user->nickname)));
+                                                                $user->nickname)),
+                            303);
         }
     }
 }
index 231f2c299280580842099f251541fbc9d2619204..d15f64498dc0c76e2fd1f5c47f20889c7e82ec37 100644 (file)
@@ -33,7 +33,9 @@ class TagAction extends Action
         }
 
         if ($this->tag != $taginput) {
-            common_redirect(common_local_url('tag', array('tag' => $this->tag)));
+            common_redirect(common_local_url('tag', array('tag' => $this->tag)),
+                            301);
+            return false;
         }
 
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
index 0d18945a09e88b2e8d2cc9b2704584cc93184be1..0c5bb7cf3ecacac93f311a47c401e0715499641b 100644 (file)
@@ -221,7 +221,8 @@ class TagotherAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url($action, array('nickname' =>
-                                                            $user->nickname)));
+                                                            $user->nickname)),
+                            303);
         }
     }
 
index bad4963534e48123352a088a4c006e93042a4bab..8573b2a873e2285492e45ee8fec5e8cbbac9bf6a 100644 (file)
@@ -116,10 +116,11 @@ class UnblockAction extends Action
             }
         }
         if ($action) {
-            common_redirect(common_local_url($action, $args));
+            common_redirect(common_local_url($action, $args), 303);
         } else {
             common_redirect(common_local_url('subscriptions',
-                                             array('nickname' => $cur->nickname)));
+                                             array('nickname' => $cur->nickname)),
+                            303);
         }
     }
 }
index b1e2b642568026cc62df626c9913105819fa3bbd..7dcab04c045d2bd3ba6e3bd2ac152e6571b184c2 100644 (file)
@@ -77,7 +77,8 @@ class UnsubscribeAction extends Action
             $this->elementEnd('html');
         } else {
             common_redirect(common_local_url('subscriptions', array('nickname' =>
-                                                                    $user->nickname)));
+                                                                    $user->nickname)),
+                            303);
         }
     }
 }
index f3769c6fce01742f3eabfe95ae741d0405e12681..3af7a39cfa2a807718fafbdd864e16af90bd7cd7 100644 (file)
@@ -171,7 +171,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
         } else if (Auth_OpenID::isFailure($redirect_url)) {
             return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
         } else {
-            common_redirect($redirect_url);
+            common_redirect($redirect_url, 303);
         }
     } else {
         // Generate form markup and render it.
index 53c807c6f9cc834aaa6955d6107e8e11a5811742..db20c580436b46e0ae4bc361d65013d2234d43d2 100644 (file)
@@ -78,9 +78,9 @@ class SettingsAction extends Action
             common_set_returnto($this->selfUrl());
             $user = common_current_user();
             if ($user->hasOpenID()) {
-                common_redirect(common_local_url('openidlogin'));
+                common_redirect(common_local_url('openidlogin'), 303);
             } else {
-                common_redirect(common_local_url('login'));
+                common_redirect(common_local_url('login'), 303);
             }
         } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $this->handlePost();