Skip to content

Commit

Permalink
Merge pull request #1329 from bcit-ci/tweaks
Browse files Browse the repository at this point in the history
Tweaks
  • Loading branch information
lonnieezell authored Oct 19, 2018
2 parents f27b8d1 + ba07b47 commit 1d1ef70
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
2 changes: 1 addition & 1 deletion system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function getCustomRowObject($n, string $className)

if ($n !== $this->currentRow && isset($this->customResultObject[$className][$n]))
{
$this->current_row = $n;
$this->currentRow = $n;
}

return $this->customResultObject[$className][$this->currentRow];
Expand Down
24 changes: 0 additions & 24 deletions system/HTTP/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,6 @@ public function withInput()
return $this;
}

/**
* Makes it so that the URL used for the redirect will include
* the Query variables in the current request.
*
* Using the $options array, can specify either only certain
* keys, or all except some vars.
*
* NOTE: Should be called after either to() or route()
*
* @param array $options
*
* @return \CodeIgniter\HTTP\RedirectResponse
*/
public function withQuery(array $options = [])
{
$queryVars = service('request')->uri->getQuery($options);

$url = $this->getHeaderLine('Location');

$this->setHeader('Location', $url.'?'.$queryVars);

return $this;
}

/**
* Adds a key and message to the session as Flashdata.
*
Expand Down
35 changes: 1 addition & 34 deletions tests/system/HTTP/RedirectResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,39 +134,6 @@ public function testWith()
$this->assertArrayHasKey('foo', $_SESSION);
}

public function testRedirectWithQueryIncludesAllVars()
{
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
$response = new RedirectResponse(new App());

$response = $response->to('http://example.com/foo')->withQuery();

$this->assertTrue($response->hasHeader('Location'));
$this->assertEquals('http://example.com/foo?foo=bar&bar=baz', $response->getHeaderLine('Location'));
}

public function testRedirectWithQueryExcept()
{
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
$response = new RedirectResponse(new App());

$response = $response->to('http://example.com/foo')->withQuery(['except' => 'foo']);

$this->assertTrue($response->hasHeader('Location'));
$this->assertEquals('http://example.com/foo?bar=baz', $response->getHeaderLine('Location'));
}

public function testRedirectWithQueryOnly()
{
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
$response = new RedirectResponse(new App());

$response = $response->to('http://example.com/foo')->withQuery(['only' => 'foo']);

$this->assertTrue($response->hasHeader('Location'));
$this->assertEquals('http://example.com/foo?foo=bar', $response->getHeaderLine('Location'));
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
Expand All @@ -178,7 +145,7 @@ public function testRedirectBack()
Services::injectMock('request', $this->request);

$response = new RedirectResponse(new App());

$returned = $response->back();
$this->assertEquals('http://somewhere.com', $returned->getHeader('location')->getValue());
}
Expand Down
11 changes: 0 additions & 11 deletions user_guide_src/source/general/common_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,6 @@ Miscellaneous Functions
// Set a flash message
return redirect()->back()->with('foo', 'message');

// Include Query vars from the current request
return redirect()->back()->withQuery();

// Include only a specific query var from the current request
return redirect()->back()->withQuery(['only' => 'foo']);
return redirect()->back()->withQuery(['only' => ['foo', 'bar']]);

// Include all query vars except specified vars from the current request
return redirect()->back()->withQuery(['except' => 'foo']);
return redirect()->back()->withQuery(['except' => ['foo', 'bar']]);

.. php:function:: remove_invisible_characters($str[, $url_encoded = TRUE])
:param string $str: Input string
Expand Down

0 comments on commit 1d1ef70

Please sign in to comment.