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

Fix undefined global variable $_SESSION in a CLI connector #16422

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

Jako
Copy link
Collaborator

@Jako Jako commented Apr 12, 2023

What does it do?

Use an empty array, if the global $_SESSION variable does not exist

Why is it needed?

Fix the warning (ERROR @ /www/core/src/Revolution/modConnectorRequest.php : 41) PHP warning: Undefined global variable $_SESSION, when a connector is called via CLI. The issue occurred first with the more strict checks of PHP 8.

How to test

It currently occurs with CronManager, when assets/components/cronmanager/cron.php is executed by CLI. Agenda has the same issue.

Related issue(s)/PR(s)

None known.

@Jako Jako requested review from opengeek and Mark-H as code owners April 12, 2023 12:04
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Apr 12, 2023
@Jako Jako added the bug The issue in the code or project, which should be addressed. label Apr 12, 2023
@MaticSulc
Copy link
Contributor

@Jako thank you for all the help.
I've also reproduced this with CronManager

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (69a7d6d) 21.75% compared to head (021461b) 21.75%.

Additional details and impacted files
@@            Coverage Diff            @@
##                3.x   #16422   +/-   ##
=========================================
  Coverage     21.75%   21.75%           
  Complexity    10478    10478           
=========================================
  Files           561      561           
  Lines         31590    31590           
=========================================
  Hits           6872     6872           
  Misses        24718    24718           
Impacted Files Coverage Δ
core/src/Revolution/modConnectorRequest.php 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@opengeek
Copy link
Member

Thanks for this, but I wonder why a connector is being called via CLI. Connectors are meant to provide web access to processors, so the fact CLI scripts are calling them is a little confusing.

@opengeek
Copy link
Member

Also, is this not an issue in 2.x?

@Jako
Copy link
Collaborator Author

Jako commented Apr 24, 2023

I have seen this CLI usage of a connector in a lot extras. The code for CLI and connector usage can be the same.

It should also be relevant in 2.x and it occurs only with the more strict checks of PHP 8 in both versions (added this above).

@opengeek opengeek added needs-backport Issues that need to be backported to the previous maintenance version. pr/port-to-2 Pull request has to be ported to 2.x. labels Apr 25, 2023
@opengeek opengeek merged commit cd8e132 into modxcms:3.x Apr 25, 2023
opengeek pushed a commit to opengeek/revolution that referenced this pull request Apr 25, 2023
@Jako Jako deleted the patch-1 branch April 25, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed. cla-signed CLA confirmed for contributors to this PR. needs-backport Issues that need to be backported to the previous maintenance version. pr/port-to-2 Pull request has to be ported to 2.x.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants