liuch / dmarc-srg

A php parser, viewer and summary report generator for incoming DMARC reports.
GNU General Public License v3.0
232 stars 35 forks source link

Error: Call to undefined function Liuch\DmarcSrg\getallheaders() #110

Closed zackw closed 11 months ago

zackw commented 11 months ago

Loading any page of the web interface causes this error to show up (both as a toast message in my browser, and in the server's error logs).

PHP Error: dmarc-srg [error]: Error: Call to undefined function Liuch\DmarcSrg\getallheaders() in .../dmarc-srg/classes/Core.php:94, referer: [redacted]

Line 94 of Core.php is the only occurrence of the word "getallheaders" in the entire source tree.

PHP 8.1.25 / Apache 2.4, on a shared webhosting service that uses their own custom CGI replacement, I don't have any details on that.

liuch commented 11 months ago

Hello @zackw Could you please let me know which version of dmarc-srg you are using?

williamdes commented 11 months ago

I am very interested in knowing in what conditions getallheaders is missing.

See: https://github.com/slimphp/Slim-Psr7/pull/273

A polyfill for the missing function: https://github.com/ralouphie/getallheaders

zackw commented 11 months ago

@liuch Git master as of this morning, rev 7c1caa3ab21f9e679be22491ac0b111d11cd43ab.

@williamdes I don't know PHP at all but searching for the error message gives me the impression that it may or may not be there depending on the "SAPI" in use. And my hosting provider has their own custom SAPI so anything I could say about it would probably be useless to you.

liuch commented 11 months ago

@williamdes This feature was not available in FPM SAPI, but has been available since version 7.3.0. I believe this issue is because of "their own CGI replacement".

liuch commented 11 months ago

@zackw Thank you for the information.

williamdes commented 11 months ago

@liuch Git master as of this morning, rev 7c1caa3.

@williamdes I don't know PHP at all but searching for the error message gives me the impression that it may or may not be there depending on the "SAPI" in use. And my hosting provider has their own custom SAPI so anything I could say about it would probably be useless to you.

If you can let me know more about the SAPI and the hosting provider name. I could keep this in mind to document in what cases this function does not exist

liuch commented 11 months ago

@zackw I have just added a polyfill for this function. Could you please test my fix?

zackw commented 11 months ago

@liuch Works, thanks for the quick fix.

@williamdes The hosting provider is https://www.nearlyfreespeech.net/. The only information I have about the SAPI is that it identifies itself as "NearlyFreeSpeech.NET PHP SAPI" in phpinfo() output, and $_SERVER['GATEWAY_INTERFACE'] is NFGI/1.0.

zackw commented 11 months ago

FWIW I hacked together a slightly different workaround which I'll attach here in case it's of use to you.

getallheaders-hack.diff

liuch commented 11 months ago

Thanks for your workaround. I'm going to rewrite mine a little later. Strictly speaking, I don't need all these checks because I use exactly one header in my code.

May I close this issue?