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] after updating to PHP 8.1 it is very slow #655

Closed
slewocom opened this issue Jan 10, 2022 · 2 comments
Closed

[BUG] after updating to PHP 8.1 it is very slow #655

slewocom opened this issue Jan 10, 2022 · 2 comments
Labels
needs investigation This will be tested / debugged or checked out.

Comments

@slewocom
Copy link

Hi there,

we have updated from PHP 7.4 to PHP 8.1 and after the update the PHP Imap email import is very slow.

We have now done a time measurement and particularly concerns the getMail function.
This function took about 3 seconds for the same email with PHP 7.4 and with PHP 8.1 the function takes over 63 seconds.
The system is the same and the PHP settings are the same.

Is this problem known and is there a solution?

@slewocom slewocom added the needs investigation This will be tested / debugged or checked out. label Jan 10, 2022
@christianasche
Copy link
Contributor

Hi there,

\PhpImap\Imap::open returns a resource with php 8.0.
But with 8.1 it returns an IMAP\Connection Object.

Source:
The IMAP functions now accept and return IMAP\Connection objects instead of imap resources.
https://www.php.net/manual/en/migration81.incompatible.php

This causes \PhpImap\Mailbox::initImapStreamWithRetry to retry the connection multiple times.

A fix could probably be to change \PhpImap\Imap::ping to something like this:

  • return \is_resource($imap_stream) && \imap_ping($imap_stream);
  • return (\is_resource($imap_stream) || $imap_stream instanceof \IMAP\Connection) && \imap_ping($imap_stream);

I think this needs further investigation.

Sebbo94BY pushed a commit that referenced this issue Jan 10, 2022
IMAP stream can be an IMAP resource or IMAP\Connection object. See https://www.php.net/manual/en/migration81.incompatible.php for further information.
Sebbo94BY added a commit that referenced this issue Jan 10, 2022
@Sebbo94BY
Copy link
Collaborator

Thanks for the bug report @slewocom !

Also thanks for the hints and solution @christianasche !

I've implemented the suggested change and tested it using different PHP versions. It seems to fix the here reported issue, which I could reproduce before and it does not break on an older PHP version as far as I could see using my tests and the PHP Unit tests.

I've released a new version 4.5.1 with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

3 participants