Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 3, 2023
2 parents 307da97 + e67b42a commit baa091c
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 31 deletions.
7 changes: 1 addition & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1461,11 +1461,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array\\|string given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc type string of property CodeIgniter\\\\Database\\\\OCI8\\\\Connection\\:\\:\\$escapeChar is not the same as PHPDoc type array\\|string of overridden property CodeIgniter\\\\Database\\\\BaseConnection\\<resource,resource\\>\\:\\:\\$escapeChar\\.$#',
'count' => 1,
Expand Down Expand Up @@ -2308,7 +2303,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 7,
'count' => 6,
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
];
$ignoreErrors[] = [
Expand Down
4 changes: 2 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,13 +1050,13 @@ public function storePreviousURL($uri)
}

if (isset($_SESSION)) {
$_SESSION['_ci_previous_url'] = URI::createURIString(
session()->set('_ci_previous_url', URI::createURIString(
$uri->getScheme(),
$uri->getAuthority(),
$uri->getPath(),
$uri->getQuery(),
$uri->getFragment()
);
));
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/Database/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public function insertID(): int
}
}

if (! $primaryColumnName) {
if ($primaryColumnName === '') {
return 0;
}

Expand Down
29 changes: 18 additions & 11 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,35 +827,42 @@ public function getUserAgent()
*/
public function getOldInput(string $key)
{
// If the session hasn't been started, or no
// data was previously saved, we're done.
if (empty($_SESSION['_ci_old_input'])) {
// If the session hasn't been started, we're done.
if (! isset($_SESSION)) {
return null;
}

// Get previously saved in session
$old = session('_ci_old_input');

// If no data was previously saved, we're done.
if ($old === null) {
return null;
}

// Check for the value in the POST array first.
if (isset($_SESSION['_ci_old_input']['post'][$key])) {
return $_SESSION['_ci_old_input']['post'][$key];
if (isset($old['post'][$key])) {
return $old['post'][$key];
}

// Next check in the GET array.
if (isset($_SESSION['_ci_old_input']['get'][$key])) {
return $_SESSION['_ci_old_input']['get'][$key];
if (isset($old['get'][$key])) {
return $old['get'][$key];
}

helper('array');

// Check for an array value in POST.
if (isset($_SESSION['_ci_old_input']['post'])) {
$value = dot_array_search($key, $_SESSION['_ci_old_input']['post']);
if (isset($old['post'])) {
$value = dot_array_search($key, $old['post']);
if ($value !== null) {
return $value;
}
}

// Check for an array value in GET.
if (isset($_SESSION['_ci_old_input']['get'])) {
$value = dot_array_search($key, $_SESSION['_ci_old_input']['get']);
if (isset($old['get'])) {
$value = dot_array_search($key, $old['get']);
if ($value !== null) {
return $value;
}
Expand Down
6 changes: 3 additions & 3 deletions system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,12 @@ function set_radio(string $field, string $value = '', bool $default = false): st
*/
function validation_errors()
{
session();
$errors = session('_ci_validation_errors');

// Check the session to see if any were
// passed along from a redirect withErrors() request.
if (isset($_SESSION['_ci_validation_errors']) && (ENVIRONMENT === 'testing' || ! is_cli())) {
return $_SESSION['_ci_validation_errors'];
if ($errors !== null && (ENVIRONMENT === 'testing' || ! is_cli())) {
return $errors;
}

$validation = Services::validation();
Expand Down
8 changes: 5 additions & 3 deletions system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ function previous_url(bool $returnObject = false)
{
// Grab from the session first, if we have it,
// since it's more reliable and safer.
// Otherwise, grab a sanitized version from $_SERVER.
$referer = $_SESSION['_ci_previous_url'] ?? Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL);
if (isset($_SESSION)) {
$referer = session('_ci_previous_url');
}

$referer ??= site_url('/');
// Otherwise, grab a sanitized version from $_SERVER.
$referer ??= request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL) ?? site_url('/');

return $returnObject ? new URI($referer) : $referer;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/system/CodeIgniterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use Tests\Support\Filters\Customfilter;

/**
* @runTestsInSeparateProcesses
*
* @backupGlobals enabled
*
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Database/Live/ForgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public function testAddFields(): void
],
];

if (version_compare($this->db->getVersion(), '8.0.17', '>=')) {
if (version_compare($this->db->getVersion(), '8.0.17', '>=') && strpos($this->db->getVersion(), 'MariaDB') === false) {
// As of MySQL 8.0.17, the display width attribute for integer data types
// is deprecated and is not reported back anymore.
// @see https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
Expand Down
16 changes: 14 additions & 2 deletions tests/system/Helpers/URLHelper/MiscUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ protected function tearDown(): void
$_SERVER = [];
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group SeparateProcess
*/
public function testPreviousURLUsesSessionFirst(): void
{
$uri1 = 'http://example.com/one?two';
$uri2 = 'http://example.com/two?foo';

$_SERVER['HTTP_REFERER'] = $uri1;
$_SESSION['_ci_previous_url'] = $uri2;
$_SERVER['HTTP_REFERER'] = $uri1;
session()->set('_ci_previous_url', $uri2);

$this->config->baseURL = 'http://example.com/public';

Expand All @@ -80,6 +86,12 @@ private function createRequest(string $uri): void
Factories::injectMock('config', 'App', $this->config);
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group SeparateProcess
*/
public function testPreviousURLUsesRefererIfNeeded(): void
{
$uri1 = 'http://example.com/one?two';
Expand Down
8 changes: 7 additions & 1 deletion tests/system/View/ParserPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ public function testCurrentURL(): void
$this->assertSame(current_url(), $this->parser->renderString($template));
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @group SeparateProcess
*/
public function testPreviousURL(): void
{
$template = '{+ previous_url +}';

// Ensure a previous URL exists to work with.
$_SESSION['_ci_previous_url'] = 'http://example.com/foo';
session()->set('_ci_previous_url', 'http://example.com/foo');

$this->assertSame(previous_url(), $this->parser->renderString($template));
}
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/libraries/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Class Reference
:returns: Attachment Content-ID or false if not found
:rtype: string

Sets and returns an attachment's Content-ID, which enables your to embed an inline
Sets and returns an attachment's Content-ID, which enables you to embed an inline
(picture) attachment into HTML. First parameter must be the already attached file name.

.. literalinclude:: email/022.php
Expand Down

0 comments on commit baa091c

Please sign in to comment.