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

Bug: Flags needs default value #4409

Closed
John-Betong opened this issue Mar 11, 2021 · 2 comments
Closed

Bug: Flags needs default value #4409

John-Betong opened this issue Mar 11, 2021 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@John-Betong
Copy link

John-Betong commented Mar 11, 2021

Info
I have been trying for over a week to trace a new site's "Network connection Error" from going down overnight. No errors in logs so added "strict_types=1" to all PHP app and system PHP files, also set .env -> CI_ENVIRONMENT = development and eventually managed to get some errors reported.

Describe the bug
incorrect type being passed.

CodeIgniter 4 version
CI_VERSION 4.1.1

Affected module(s)
File: ./system/HTTP/RequestTrait.php
[code]
public function fetchGlobal($method, $index = null, $filter = null, $flags = null)
{
$method = strtolower($method);

	if (! isset($this->globals[$method]))
	{
		$this->populateGlobals($method);
	}

	// Null filters cause null values to return.
	if (is_null($filter))
	{
		$filter = FILTER_DEFAULT;
	}

	// Return all values when $index is null
	if (is_null($index))
	{
		$values = [];
		foreach ($this->globals[$method] as $key => $value)
		{
			# PROBLEM 2021-03-09
			  $flags = $flags ?? 0;

			$values[$key] = is_array($value)
				? $this->fetchGlobal($method, $key, $filter, $flags)
				: filter_var($value, $filter, $flags);
		}

		return $values;
	}

[/code]

Expected behavior, and steps to reproduce if appropriate
I did not expect the web page to crash :(

Context

  • OS: [Ubuntu 20.04.1]
  • Web server [Apache 2]
  • PHP version [8.0.3]
@John-Betong John-Betong added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 11, 2021
@MGatner MGatner changed the title Bug: Bug: Flags needs default value Mar 11, 2021
@MGatner
Copy link
Member

MGatner commented Mar 11, 2021

Similar problems in:

@paulbalandan
Copy link
Member

Fixed by #4390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

3 participants