Skip to content

Commit 1d1ef70

Browse files
authored
Merge pull request #1329 from bcit-ci/tweaks
Tweaks
2 parents f27b8d1 + ba07b47 commit 1d1ef70

4 files changed

Lines changed: 2 additions & 70 deletions

File tree

system/Database/BaseResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public function getCustomRowObject($n, string $className)
344344

345345
if ($n !== $this->currentRow && isset($this->customResultObject[$className][$n]))
346346
{
347-
$this->current_row = $n;
347+
$this->currentRow = $n;
348348
}
349349

350350
return $this->customResultObject[$className][$this->currentRow];

system/HTTP/RedirectResponse.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,30 +139,6 @@ public function withInput()
139139
return $this;
140140
}
141141

142-
/**
143-
* Makes it so that the URL used for the redirect will include
144-
* the Query variables in the current request.
145-
*
146-
* Using the $options array, can specify either only certain
147-
* keys, or all except some vars.
148-
*
149-
* NOTE: Should be called after either to() or route()
150-
*
151-
* @param array $options
152-
*
153-
* @return \CodeIgniter\HTTP\RedirectResponse
154-
*/
155-
public function withQuery(array $options = [])
156-
{
157-
$queryVars = service('request')->uri->getQuery($options);
158-
159-
$url = $this->getHeaderLine('Location');
160-
161-
$this->setHeader('Location', $url.'?'.$queryVars);
162-
163-
return $this;
164-
}
165-
166142
/**
167143
* Adds a key and message to the session as Flashdata.
168144
*

tests/system/HTTP/RedirectResponseTest.php

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -134,39 +134,6 @@ public function testWith()
134134
$this->assertArrayHasKey('foo', $_SESSION);
135135
}
136136

137-
public function testRedirectWithQueryIncludesAllVars()
138-
{
139-
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
140-
$response = new RedirectResponse(new App());
141-
142-
$response = $response->to('http://example.com/foo')->withQuery();
143-
144-
$this->assertTrue($response->hasHeader('Location'));
145-
$this->assertEquals('http://example.com/foo?foo=bar&bar=baz', $response->getHeaderLine('Location'));
146-
}
147-
148-
public function testRedirectWithQueryExcept()
149-
{
150-
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
151-
$response = new RedirectResponse(new App());
152-
153-
$response = $response->to('http://example.com/foo')->withQuery(['except' => 'foo']);
154-
155-
$this->assertTrue($response->hasHeader('Location'));
156-
$this->assertEquals('http://example.com/foo?bar=baz', $response->getHeaderLine('Location'));
157-
}
158-
159-
public function testRedirectWithQueryOnly()
160-
{
161-
$this->request->uri->setQueryArray(['foo' => 'bar', 'bar' => 'baz']);
162-
$response = new RedirectResponse(new App());
163-
164-
$response = $response->to('http://example.com/foo')->withQuery(['only' => 'foo']);
165-
166-
$this->assertTrue($response->hasHeader('Location'));
167-
$this->assertEquals('http://example.com/foo?foo=bar', $response->getHeaderLine('Location'));
168-
}
169-
170137
/**
171138
* @runInSeparateProcess
172139
* @preserveGlobalState disabled
@@ -178,7 +145,7 @@ public function testRedirectBack()
178145
Services::injectMock('request', $this->request);
179146

180147
$response = new RedirectResponse(new App());
181-
148+
182149
$returned = $response->back();
183150
$this->assertEquals('http://somewhere.com', $returned->getHeader('location')->getValue());
184151
}

user_guide_src/source/general/common_functions.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,6 @@ Miscellaneous Functions
244244
// Set a flash message
245245
return redirect()->back()->with('foo', 'message');
246246

247-
// Include Query vars from the current request
248-
return redirect()->back()->withQuery();
249-
250-
// Include only a specific query var from the current request
251-
return redirect()->back()->withQuery(['only' => 'foo']);
252-
return redirect()->back()->withQuery(['only' => ['foo', 'bar']]);
253-
254-
// Include all query vars except specified vars from the current request
255-
return redirect()->back()->withQuery(['except' => 'foo']);
256-
return redirect()->back()->withQuery(['except' => ['foo', 'bar']]);
257-
258247
.. php:function:: remove_invisible_characters($str[, $url_encoded = TRUE])
259248
260249
:param string $str: Input string

0 commit comments

Comments
 (0)