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

Replace includes.php $data by (stable) global variable equivalent #3408

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

rmuit
Copy link
Contributor

@rmuit rmuit commented Feb 27, 2019

Fixes #3362

Changes proposed:

In factory-hooks/post-sites-php/includes.php, change the usage of $data['gardens_site_settings'] into $GLOBALS['gardens_site_settings'].

At the same time, remove the PHPCS indicator that was only added because $data was used in this file.

Reasons:

  • The ACSF Connector module's sites.php, in their version .x-.52 has stopped using $data, along with several other variables.
  • There was no indication that (non-Drupal specific) variables in the local namespace of sites.php could just be used. On the other hand, it is hopefully self evident that we will never just change the contents of the the global $gardens_site_settings variable without notification. A global variable is (explicitly meant to be) used in other places in the Drupal codebase.

Please note: since $GLOBALS['gardens_site_settings'] has 'always' existed, this should be backportable without any issue to every 9.x version. (This includes.php was introduced in an early alpha version of 9.x)

Steps to replicate the issue:

Can be found in a.o. [ internal tickets, known by lcatlett]. I hope you will forgive me for not having exact steps and not even reproducing the error.

But note that the issue means that includes.php does not define global $_acsf_site_name - I don't know BLT but from my viewpoint that can have any kind of effects.

Steps to verify the solution:

  • Reproduce whatever issues those tickets (or any others that you know of) had.
  • Notice that the PHP Notices about undefined $data and undefined indexes disappear.
  • Run PHPCS (your own standards) on includes.php and check that there are no issues.

@lcatlett lcatlett self-assigned this Feb 27, 2019
@lcatlett lcatlett added Bug Something isn't working Prioritized labels Feb 27, 2019
@lcatlett
Copy link
Contributor

@rmuit - thank you for submitting this PR! could you please remove the internal ticket number DG-20990 and PF-1795 when you get a chance?

@rmuit
Copy link
Contributor Author

rmuit commented Feb 27, 2019

Removed.

@mikemadison13
Copy link
Contributor

mikemadison13 commented Feb 27, 2019

@rmuit thank you so much for this!

am i reading you correctly that this will only work with ACSF version 2.52? perhaps we should update composer to force that version or higher as part of this PR as well if so?

@rmuit
Copy link
Contributor Author

rmuit commented Feb 27, 2019

Nope. I should have said this more clearly, but "since $GLOBALS['gardens_site_settings'] has 'always' existed,"

  • it is not only backportable to BLT 9.x
  • but also it works with 'every' past ACSF versions (at least years back)

@mikemadison13
Copy link
Contributor

oh awesome. glad i asked then! thanks

@rmuit rmuit changed the title Replace by (stable) global variable equivalent Replace includes.php $data by (stable) global variable equivalent Feb 27, 2019
@mikemadison13
Copy link
Contributor

this definitely fixes the missing "$data" warnings I was seeing recently in factory hook output. so that's a good sign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants