Z-Hub / Z-Push

Home of Z-Push
https://z-push.org
GNU Affero General Public License v3.0
94 stars 43 forks source link

PHP 8.3 Uncaught TypeError: backend/imap/imap.php #44

Closed dborg89 closed 9 months ago

dborg89 commented 9 months ago

Server: nginx + php8.3-fpm

Behaviour: When running z-push on php 8.3 I am getting fatal error from the imap backend causing it to kill the execution.

Log Data 2024/01/11 06:35:17 [error] 3293085#3293085: *5391 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, false given in /srv/z-push/backend/imap/imap.php:1132 Stack trace:

0 /srv/z-push/backend/imap/imap.php(1132): implode()

1 /srv/z-push/lib/default/diffbackend/exportchangesdiff.php(160): BackendIMAP->GetMessage()

2 /srv/z-push/lib/request/sync.php(1199): ExportChangesDiff->Synchronize()

3 /srv/z-push/lib/request/sync.php(956): Sync->syncFolder()

4 /srv/z-push/lib/request/requestprocessor.php(116): Sync->Handle()

5 /srv/z-push/index.php(107): RequestProcessor::HandleRequest()

6 {main}

thrown in /srv/z-push/backend/imap/imap.php on line 1132" while reading response header from upstream, client: REDACTED, server: REDACTED, request: "POST /Microsoft-Server-ActiveSync/?Cmd=Sync&User=REDACTED&DeviceId=REDACTED&DeviceType=REDACTED HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.3-fpm.sock:", host: "REDACTED"

Code in question ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage('%s', '%s', '%s')", $folderid, $id, implode(",", $bodypreference)));

Workaround Reverting to php 7.4 at present to get around this.

Cause

Implode with historical parameter order (https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.implode-reverse-parameters) Passing parameters to implode() in reverse order is deprecated, use implode($glue, $parts) instead of implode($parts, $glue)

matidau commented 9 months ago

Hi @dborg89

Can you use the the latest from the repo.

Believe this was already fixed in this commit https://github.com/Z-Hub/Z-Push/commit/bdbdd8fd2785cbbcb54a2e07c8e6e95a51030e9a by @DoobleD

Cheers, Mat

Edit: giving credit for the commit 😊

matidau commented 9 months ago

Indeed this works! Apologies for not noticing it in the commit history (just downloaded the latest stable from the releases section when I last updated).

Thanks :)

Originally posted by @dborg89 in https://github.com/Z-Hub/Z-Push/pull/31#issuecomment-1887995709

Will close this off now 😊