Updated to PHP 8.4, now EmailReporting throws error 500

This plugin allows you to report an issue in MantisBT by sending an email to a particular mail account

Moderators: Developer, Contributor

Post Reply
gurksallad
Posts: 28
Joined: 30 Jan 2020, 07:42

Updated to PHP 8.4, now EmailReporting throws error 500

Post by gurksallad »

Earlier today we ran PHP 8.0 on our hosting system. That version is outdated so we had to upgrade to 8.4. After this upgrade, the scheduled jobs for ER does not work.

Running

Code: Select all

/plugins/EmailReporting/scripts/bug_report_mail.php
gives "Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request.". We do unfortunately not have access to the server logs so we cannot read what happened.

If we run this script manually from a terminal, we get this output:

Code: Select all

:~$ ./update_mantis.sh
   cron_run_jobs.php cronjobid: 2 priority=10 entity=1
   label=SendEmailsReminders - not qualified (datenextrunok=0, datestartok=1,
   dateendok=1) Result: 1 jobs - 0 launched = 0 OK + 0 KO
On PHP 8.0 we got this output:

Code: Select all

 Start checking all mailboxes: Wednesday 25th of February 2026 13:40:50

 Done checking all mailboxes
Is this a known issue for ER? We use Mantis v2.26.2 and ER 0.10.1.
gurksallad
Posts: 28
Joined: 30 Jan 2020, 07:42

Re: Updated to PHP 8.4, now EmailReporting throws error 500

Post by gurksallad »

The hosting support now helped us enable PHP errors, so when running the script locally we see this:

Code: Select all

:$ php bug_report_mail.php

Fatal error: Duplicate declaration of static variable $indent in /customers/(censored)/mantis/plugins/EmailReporting/core/Mail/Markdownify/Converter.php on line 560
Is there a quick fix for this?
gurksallad
Posts: 28
Joined: 30 Jan 2020, 07:42

Re: Updated to PHP 8.4, now EmailReporting throws error 500

Post by gurksallad »

Alright, I had to learn a bit PHP language and the "static" keyword.

Just like the error message says, the static $indent is declarated twice. Its only use is in the same if-case and it obviously gets called twice. In Converter.php I moved up the static declaration to line 531 (so it's declared only once) and removed the declarations on line 538 and 560. Then I re-ran the updater script and it works like it should.
atrol
Site Admin
Posts: 8555
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Updated to PHP 8.4, now EmailReporting throws error 500

Post by atrol »

Looks like a known issue https://github.com/Elephant418/Markdownify/issues/47
Unfortunately still not fixed, as the PR to fix it is still not merged https://github.com/Elephant418/Markdownify/pull/49
Please use Search before posting and read the Manual
SL-Gundam
Posts: 764
Joined: 06 Jul 2011, 14:17

Re: Updated to PHP 8.4, now EmailReporting throws error 500

Post by SL-Gundam »

While that is correct, there were 2 pull requests which concerned these issues which are related to PHP 8.3 compatibility
The necessary changes were incorporated in EmailReporting 0.11.0-DEV

The Pull requests
https://github.com/Elephant418/Markdownify/pull/48
https://github.com/Elephant418/Markdownify/pull/49

The changes to emailreporting concerning PHP 8.3 (and 8.4) compatibility (there are more but these concern the issue mentioned)
https://github.com/mantisbt-plugins/Ema ... 960b7f062d
https://github.com/mantisbt-plugins/Ema ... bc546ff273

Please update to the latest 0.11.0-DEV version and everything should work properly.
Post Reply