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

PHP8 - Fatal error with some imap attachments? #734

Closed
mcbmcb0 opened this issue Jul 21, 2023 · 7 comments
Closed

PHP8 - Fatal error with some imap attachments? #734

mcbmcb0 opened this issue Jul 21, 2023 · 7 comments

Comments

@mcbmcb0
Copy link

mcbmcb0 commented Jul 21, 2023

💬 Question

I've put this as a questions tho I think its a bug due to php making count types compulsory. but I don't know how to reliably reproduce it:

PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /var/www/cypht/modules/imap/functions.php:914
Stack trace:
#0 /var/www/cypht/modules/imap/functions.php(476): get_imap_part_name()
#1 /var/www/cypht/modules/imap/functions.php(410): get_part_desc()
#2 /var/www/cypht/modules/imap/functions.php(534): format_msg_part_row()
#3 /var/www/cypht/modules/imap/functions.php(540): format_msg_part_section()
#4 /var/www/cypht/modules/imap/output_modules.php(152): format_msg_part_section()
#5 /var/www/cypht/lib/module.php(526): Hm_Output_filter_message_struct->output()
#6 /var/www/cypht/lib/modules_exec.php(96): Hm_Output_Module->output_content()
#7 /var/www/cypht/lib/modules_exec.php(83): Hm_Module_Exec->process_result()
#8 /var/www/cypht/lib/modules_exec.php(43): Hm_Module_Exec->run_output_module()
#9 /var/www/cypht/lib/dispatch.php(235): Hm_Module_Exec->run_output_modules()
#10 /var/www/cypht/lib/dispatch.php(190): Hm_Dispatch->process_request()
#11 /var/www/cypht/site/index.php(50): Hm_Dispatch->__construct()
#12 {main}\n  thrown in /var/www/cypht/modules/imap/functions.php on line 914

the offending code is:
for ($i=0;$i<count($struct['disposition']['attachment']);$i++) {
I assume there are no attachments tho they are expected. This line has not been updated in the latest current release. I've hacked a quick fix until someone can replicate this and/or patch it:
for ($i=0;$i<count( is_countable($struct['disposition']['attachment']??null) ? $struct['disposition']['attachment']: [] );$i++) {

thanks

@marclaporte
Copy link
Member

@josaphatim What do you think?

@josaphatim
Copy link
Member

@josaphatim What do you think?

@mcbmcb0, @marclaporte I couldn't really reproduce that by as error is clear I'll proposed a merge request

@marclaporte
Copy link
Member

@mcbmcb0 Please confirm the issue is solved in master.

@mcbmcb0
Copy link
Author

mcbmcb0 commented Sep 8, 2023

Hi
while I still don't know how to force the error, the current master appears to work for me on php8.2 / debian 12.
thanks!

EDIT: but i do now notice:
PHP Warning: foreach() argument must be of type array|object, int given in /var/www/cypht/modules/imap/functions.php on line 1390, referer: https://XXXXXX/admin/cypht
unfortunately i haven't had time to look into it.

@josaphatim
Copy link
Member

modules/imap/functions.php

This is the fix for it #759.

@marclaporte
Copy link
Member

@mcbmcb0 Please confirm the issue is solved in master.

@mcbmcb0
Copy link
Author

mcbmcb0 commented Sep 9, 2023

yes, this issue now resolved. thanks

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

No branches or pull requests

3 participants