Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks #1329

Merged
merged 2 commits into from
Oct 19, 2018
Merged

Tweaks #1329

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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