Skip to content

refactor: remove unused non-empty array in RequestTrait - #7606

Closed
paulbalandan wants to merge 1 commit into
codeigniter4:developfrom
paulbalandan:refactor-request-trait
Closed

paulbalandan wants to merge 1 commit into
codeigniter4:developfrom
paulbalandan:refactor-request-trait

Conversation

@paulbalandan

@paulbalandan paulbalandan commented Jun 22, 2023

Copy link
Copy Markdown
Member

Description
Brought by RemoveUnusedNonEmptyArrayBeforeForeachRector but manually made as I cannot use rector on Windows.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis

kenjis commented Jun 22, 2023

Copy link
Copy Markdown
Member

The $proxyIPs value may be an empty string if Config\App is not updated.

* Comma-separated: '10.0.1.200,192.168.5.0/24'
* Array: ['10.0.1.200', '192.168.5.0/24']
*
* @var string|string[]
*/
public $proxyIPs = '';

In this case, this change causes:

ErrorException
foreach() argument must be of type array|object, string given
SYSTEMPATH/HTTP/RequestTrait.php at line 82

@kenjis kenjis added the refactor Pull requests that refactor code label Jun 22, 2023
@paulbalandan

Copy link
Copy Markdown
Member Author

Ok. Judging by how $this->proxyIPs is injected with value, L68 should be revised to check that $proxyIPs should be an array even if empty or not.

@kenjis

kenjis commented Jun 24, 2023

Copy link
Copy Markdown
Member

It is better to set [] if $proxyIPs = ''. Many devs do not use Proxy at all.

Or add "$proxyIPs must be an array" to Mandatory File Changes in the upgrade guide.

@kenjis

kenjis commented Jun 26, 2023

Copy link
Copy Markdown
Member

I sent another PR #7620
and will make sure $proxyIPs is an array in 4.4. See #7621

@kenjis kenjis closed this in #7620 Jun 26, 2023
@paulbalandan
paulbalandan deleted the refactor-request-trait branch June 26, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants