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

CiviReport - avoid error in test environments when using built-in php web server #21560

Merged
merged 1 commit into from
Sep 21, 2021

Conversation

demeritcowboy
Copy link
Contributor

Overview

Admittedly this is not something that comes up in core, but is a straightforward "if variable doesn't exist yet don't try to append to it".

Before

Error: $_SERVER['QUERY_STRING'] undefined

After

Technical Details

Came up during https://lab.civicrm.org/extensions/cdntaxreceipts/-/merge_requests/153#note_65360 where it seems in apache $_SERVER['QUERY_STRING'] is always at least set to '', whereas in php's built-in web server it might not exist.

The point being in different web server environments you can't assume $_SERVER array members already exist.

Comments

I've labelled "Has Test" in the sense that the above noted unit test is intended to be a regularly run test just not as part of the core tests. And that's how this came up. Feel free to remove.

@civibot
Copy link

civibot bot commented Sep 21, 2021

(Standard links)

@civibot civibot bot added the master label Sep 21, 2021
@@ -626,6 +626,10 @@ public function preProcessCommon() {

// set qfkey so that pager picks it up and use it in the "Next > Last >>" links.
// FIXME: Note setting it in $_GET doesn't work, since pager generates link based on QUERY_STRING
if (!isset($_SERVER['QUERY_STRING'])) {
// in php 7.4 can do this with less lines with ??=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh - interesting - I didn't know that. Let's ditch php 7.3 support today....

@eileenmcnaughton
Copy link
Contributor

Agree there is not much risk / downside here

@eileenmcnaughton eileenmcnaughton merged commit 2746b3d into civicrm:master Sep 21, 2021
@demeritcowboy
Copy link
Contributor Author

Thanks!

@demeritcowboy demeritcowboy deleted the report-query-string branch September 21, 2021 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants