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

Api.php: getMauticVersion() always returns null due to header key is lower-case #233

Closed
HerbergSystems opened this issue Jan 15, 2021 · 4 comments · Fixed by #302
Closed
Labels

Comments

@HerbergSystems
Copy link

HerbergSystems commented Jan 15, 2021

In Method getMauticVersion():

public function getMauticVersion()`
     {
       $headers = $this->auth->getResponseHeaders();

       if (isset($headers['Mautic-Version'])) {
           return $headers['Mautic-Version'];
       }

       return null;
   }

Unfortunately, the header (at least on our Mautic installation on Debian Buster) is all lower-case: "mautic-version", not "Mautic-Version". So, this method will always return null.

Solution:

Avoid case-sensitive checks on headers here. Simple workaround (could be done better...):

public function getMauticVersion()
   {
       $headers = $this->auth->getResponseHeaders();

       if (isset($headers['Mautic-Version'])) {
           return $headers['Mautic-Version'];
       }
       if (isset($headers['mautic-version'])) {
           return $headers['mautic-version'];
       }

       return null;
   }

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@HerbergSystems HerbergSystems changed the title Api.php: getMauticVersion()` always returns null due to header key is lower-case Api.php: getMauticVersion() always returns null due to header key is lower-case Jan 15, 2021
@dennisameling
Copy link
Member

Hi @HerbergSystems, thanks for reporting this! I've seen this in other PHP applications before - some webservers seem to convert header keys to lowercase. Could you please test #240? That should fix it!

@HerbergSystems
Copy link
Author

HerbergSystems commented Feb 25, 2021 via email

@Moongazer
Copy link
Contributor

Moongazer commented Sep 1, 2022

I'm having the same issue on my webserver and can confirm that the solution #240 works, please merge it into the next release, thanks!

Edit:
The reason for the header change in our case is probably the Nginx, which sits as reverse-proxy before the Mautic instance running on Apache.

@escopecz
Copy link
Member

escopecz commented Sep 2, 2022

Thanks for testing! Please approve the PR itself. Your test may me overlooked in the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants