? 361150_querystring_simple_with_tests-D6.patch
Index: path_redirect.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_redirect/path_redirect.admin.inc,v
retrieving revision 1.1.2.85
diff -u -p -r1.1.2.85 path_redirect.admin.inc
--- path_redirect.admin.inc	6 Oct 2010 15:50:13 -0000	1.1.2.85
+++ path_redirect.admin.inc	18 Oct 2010 14:14:27 -0000
@@ -505,6 +505,13 @@ function path_redirect_settings_form() {
     '#title' => t('Allow users to bypass redirects by adding %code to the URL.', array('%code' => variable_get('clean_url', 0) ? '?redirect=no' : '&redirect=no')),
     '#default_value' => variable_get('path_redirect_allow_bypass', 0),
   );
+  $form['path_redirect_retain_query_string'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Include incoming URL query string in redirect'),
+    '#default_value' => variable_get('path_redirect_retain_query_string', FALSE),
+    '#description' => t("Allow query strings on the source URL to carry forward to the redirected URL. If enabled, the query string on an incoming URL is merged with the query string stored with the redirect URL if any (query string components from the incoming URL will be overwritten by saved values)."),
+  );
+
   $form['path_redirect_auto_redirect'] = array(
     '#type' => 'checkbox',
     '#title' => t('Automatically create redirects when URL aliases are changed.'),
Index: path_redirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_redirect/path_redirect.module,v
retrieving revision 1.3.2.7.2.107
diff -u -p -r1.3.2.7.2.107 path_redirect.module
--- path_redirect.module	7 Oct 2010 15:28:33 -0000	1.3.2.7.2.107
+++ path_redirect.module	18 Oct 2010 14:14:27 -0000
@@ -115,6 +115,11 @@ function path_redirect_goto($redirect = 
   }
 
   if ($redirect) {
+    if (variable_get('path_redirect_retain_query_string', FALSE)) {
+      // Append to query string on redirect URL
+      // Values from the stored redirect will override those specified in the request if they collide.
+      $redirect['query'] = array_merge($query, $redirect['query']);
+    }
     // Create the absolute redirection URL.
     $redirect['redirect_url'] = url($redirect['redirect'], array('query' => $redirect['query'], 'fragment' => $redirect['fragment'], 'absolute' => TRUE));
 
@@ -606,6 +611,7 @@ function path_redirect_get_query_array($
 
 function path_redirect_variables() {
   return array(
+    'path_redirect_retain_query_string' => FALSE,
     'path_redirect_redirect_warning' => 0,
     'path_redirect_allow_bypass' => 0,
     'path_redirect_auto_redirect' => 1,
Index: path_redirect.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_redirect/path_redirect.test,v
retrieving revision 1.1.2.23
diff -u -p -r1.1.2.23 path_redirect.test
--- path_redirect.test	9 Aug 2010 18:39:59 -0000	1.1.2.23
+++ path_redirect.test	18 Oct 2010 14:14:27 -0000
@@ -23,12 +23,12 @@ class PathRedirectTestHelper extends Dru
     call_user_func_array($parent_callback, $modules);
   }
 
-  protected function assertRedirect($request, $redirect, $code = FALSE) {
-    $this->drupalGet($request);
+  protected function assertRedirect($request, $redirect, $options = array(), $code = FALSE) {
+    $this->drupalGet($request, $options);
     if ($code) {
       $this->assertResponse($code);
     }
-    $this->assertEqual($this->getUrl(), url($redirect, array('absolute' => TRUE)), t('Redirected from %request to %redirect.', array('%request' => $request, '%redirect' => $redirect)));
+    $this->assertEqual($this->getUrl(), url($redirect, array('absolute' => TRUE) + $options), t('Redirected from %request to %redirect.', array('%request' => $request, '%redirect' => $redirect)));
   }
 
   protected function addRedirect($source, $redirect, $options = array()) {
@@ -73,19 +73,19 @@ class PathRedirectUnitTest extends PathR
     }
   }
 
-  function testRedirects() {
+  function testRedirects($options = array()) {
     // Test a basic redirect (with and without a trailing slash requested).
     $this->addRedirect('/test/', 'node');
-    $this->assertRedirect('test', 'node');
-    $this->assertRedirect('test/', 'node');
+    $this->assertRedirect('test', 'node', $options);
+    $this->assertRedirect('test/', 'node', $options);
 
     // Test a unicode URL.
     $this->addRedirect('FrançAIS', 'http://example.com/');
-    $this->assertRedirect('FrançAIS', 'http://example.com/');
+    $this->assertRedirect('FrançAIS', 'http://example.com/', $options);
 
     // Test an URL with special characters.
     $this->addRedirect('foo_/ferzle-foo.bar', '<front>');
-    $this->assertRedirect('foo_/ferzle-foo.bar', '<front>');
+    $this->assertRedirect('foo_/ferzle-foo.bar', '<front>', $options);
   }
 
   function testNoCleanURLs() {
@@ -94,6 +94,14 @@ class PathRedirectUnitTest extends PathR
     $this->testRedirects();
     variable_set('clean_url', (int) $clean_url);
   }
+
+  function testQueryStrings() {
+    $options = array('query' => 'retain_query_string=test');
+    $retain_query_string = (bool) variable_get('path_redirect_retain_query_string', FALSE);
+    variable_set('path_redirect_retain_query_string', !$retain_query_string);
+    $this->testRedirects($options);
+    variable_set('path_redirect_retain_query_string', $retain_query_string);
+  }
 }
 
 /*class PathRedirectPathautoUnitTest extends PathRedirectTestHelper {
