Skip to content

Fixed, PHP Warning: Invalid argument supplied for foreach(), cast array#64

Merged
ralfbecker merged 2 commits intoEGroupware:17.1from
asig2016:17.1_fix1
Mar 6, 2019
Merged

Fixed, PHP Warning: Invalid argument supplied for foreach(), cast array#64
ralfbecker merged 2 commits intoEGroupware:17.1from
asig2016:17.1_fix1

Conversation

@asig2016
Copy link
Contributor

@asig2016 asig2016 commented Mar 5, 2019

Error message during setup:

2019/03/05 22:12:42 [error] 1276#1276: *36 FastCGI sent in stderr: "PHP message: PHP Warning: Invalid argument supplied for foreach() in /home/asig/dev/egw/egwdev2/html/egw/filemanager/inc/class.filemanager_hooks.inc.php on line 237
PHP message: #1 /home/asig/dev/egw/egwdev2/html/egw/api/src/loader/deprecated_factory.php(179): filemanager_hooks::settings(Array)
PHP message: #2 /home/asig/dev/egw/egwdev2/html/egw/setup/inc/class.setup.inc.php(719): ExecMethod('filemanager_hoo...', Array)
PHP message: #3 /home/asig/dev/egw/egwdev2/html/egw/setup/inc/class.setup_process.inc.php(463): setup->set_default_preferences('filemanager')
PHP message: #4 /home/asig/dev/egw/egwdev2/html/egw/setup/inc/class.setup_process.inc.php(147): setup_process->current(Array, NULL)
PHP message: #5 /home/asig/dev/egw/egwdev2/html/egw/setup/index.php(349): setup_process->pass(Array, 'new', NULL, NULL)
PHP message: #6 {main}

@asig2016 asig2016 closed this Mar 6, 2019
@asig2016 asig2016 deleted the 17.1_fix1 branch March 6, 2019 08:56
@asig2016 asig2016 restored the 17.1_fix1 branch March 6, 2019 09:07
@asig2016
Copy link
Contributor Author

asig2016 commented Mar 6, 2019

I thought there was a simpler solution that's why I closed the PR temporary.

@asig2016 asig2016 reopened this Mar 6, 2019
@ralfbecker
Copy link
Member

Hi Alexandros,

I have not merged this for 2 reasons:
a) coding standards: brackets should be on the next line
b) having an if clause around every foreach does not improve readability, so in case of a not set parameter, like this one, I prefer the following code:
foreach ((array)$editorLink['mime'] as $mime => $value)
That casts a not set attribute like 'mime' here to an empty array.
Of cause that only works for not set, not for things like false!

Please change your pull request to a cast.

Keep up the good work :)

Ralf

@asig2016 asig2016 changed the title Fixed, PHP message: PHP Warning: Invalid argument supplied for foreach() Fixed, PHP Warning: Invalid argument supplied for foreach(), cast array Mar 6, 2019
@ralfbecker ralfbecker merged commit 5d3d3a9 into EGroupware:17.1 Mar 6, 2019
@ralfbecker
Copy link
Member

Thanks :)

@asig2016 asig2016 deleted the 17.1_fix1 branch March 6, 2019 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants