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(requirement-checker): Do not execute any requirement checker code when the requirement checker is disabled #851

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions requirement-checker/bin/check-requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@

namespace KevinGH\RequirementChecker;

require __DIR__.'/../vendor/autoload.php';
if (
isset($_SERVER['BOX_REQUIREMENT_CHECKER'])
|| false === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER']
) {
// Do nothing.
return;
}

// Important: do this check _after_ the requirement checker flag. Indeed, if the requirement checker is disabled we do
// not want any of its code to be executed.

// See https://github.com/easysoft/phpmicro for the micro SAPI.
if (false === in_array(PHP_SAPI, array('cli', 'phpdbg', 'embed', 'micro'), true)) {
Expand All @@ -21,11 +30,8 @@
exit(1);
}

if ((
false === isset($_SERVER['BOX_REQUIREMENT_CHECKER'])
|| true === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER']
)
&& false === Checker::checkRequirements()
) {
require __DIR__.'/../vendor/autoload.php';

if (Checker::checkRequirements()) {
exit(1);
}