Skip to content

Bug: Flags needs default value #4409

Closed
Closed
@John-Betong

Description

@John-Betong

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]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions