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

Simplify PHP version error message in index.php, install.php, api.php… #2982

Closed
wants to merge 1 commit into from

Conversation

justinbeaty
Copy link
Contributor

@justinbeaty justinbeaty commented Jan 19, 2023

Description (*)

The hardcoded HTML in some root files has always bothered me. First, it contains broken html: (two closing </a>)

<a href="https://www.openmage.org/magento-lts/install.html" target="">Find out</a> how to install</a>

But also, we really don't need those inline styles. It looks fine considering nobody should see it.

image

I also created the $minVersion variable so we don't have to change it twice in each file.

Manual testing scenarios (*)

  1. Change $minVersion to 9.0.0 or similar to see the error message.

Questions or comments

Can we move $minVersion to some file that gets included so we don't have to duplicate it?

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@sreichel
Copy link
Contributor

Can we move $minVersion to some file that gets included so we don't have to duplicate it?

I guess until Mage:app() isnt called, we cannot.

@justinbeaty
Copy link
Contributor Author

Can we move $minVersion to some file that gets included so we don't have to duplicate it?

I guess until Mage:app() isnt called, we cannot.

I was thinking like:

config.php:

<?php
$minVersion = '7.3.0';

and in [index|install|api|get].php:

require_once __DIR__ . '/config.php';
if (version_compare(phpversion(), $minVersion, '<') === true) {

But, it's kind of pointless to have a config.php with just one variable and it's easy enough to update in each of the four files whenever the min PHP version changes. I was just kind of throwing out ideas.

@sreichel
Copy link
Contributor

I can live w/o, but can we add styling to some css-files? 😎

@fballiano
Copy link
Contributor

In my opinion I would remove that message, we don’t check php extensions or any other thing, only php version.. I don’t see its utility this much as to have it in every call.

@justinbeaty
Copy link
Contributor Author

I wouldn't bother to add any CSS to the message, literally nobody should ever see it.

I also don't care if we remove it, I already do that in my local fork. But perhaps more people should put in their opinion on removing it.

@justinbeaty justinbeaty marked this pull request as draft January 20, 2023 00:54
@justinbeaty
Copy link
Contributor Author

justinbeaty commented Jan 20, 2023

Converting to draft since I think (if we choose to keep it) that we can put it into bootstrap.php. Maybe also check for PHP modules there, which could be useful now that IIRC we require intl.

@fballiano
Copy link
Contributor

As we were saying in another pr we could have a system check page instead of checking at every request

@justinbeaty
Copy link
Contributor Author

justinbeaty commented Jan 20, 2023

As we were saying in another pr we could have a system check page instead of checking at every request

Yes, but if the error is an incompatible PHP version or a missing module, it’s possible the user may not be able to reach that page.

Anyway, I will be off until tomorrow morning. Will modify this PR then, and then it’s up to the community/maintainers on what direction to go.

@fballiano
Copy link
Contributor

It could be memory setting or many other parameters. Some projects have a system check script to call on cli

@sreichel
Copy link
Contributor

sreichel commented Jan 20, 2023

As we were saying in another pr we could have a system check page instead of checking at every request

N98 magerun provides sys:check command ... head over here netz98/n98-magerun#1275 and lets finish this.

@luigifab
Copy link
Contributor

I suggest to move it to Mage.php (like my root check even you are unhappy), or to drop it, :).
When OpenMage is installed with composer, composer check PHP version at every request.

@@ -113,9 +113,13 @@
*
*/

if (version_compare(phpversion(), '7.3.0', '<') === true) {
die('ERROR: Whoops, it looks like you have an invalid PHP version. OpenMage supports PHP 7.3.0 or newer.');
Copy link
Member

Choose a reason for hiding this comment

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

install.php is meant to be invoked from the cli, I think that's why there wasn't HTML before.

@justinbeaty
Copy link
Contributor Author

When OpenMage is installed with composer, composer check PHP version at every request.

@luigifab is right. As long as you don't install with --ignore-platform-reqs (although --ignore-platform-req=ext-* is okay) then the file vendor/composer/platform_check.php checks PHP versions in the autoloader.

Since the release builder has the composer autoloader, then all new releases will check PHP version already. So I would vote to close this PR and open another to simply remove these lines from the root files.

Although one small note: platform_check.php wants >= 7.4.0. This is because: OpenMage requires magento-composer-installer, which requires symfony/console, which requires symfony/service-contracts, which requires psr/container, which requires "php": ">=7.4.0".

So we should bump the min required version, or remove magento-composer-installer in the built files which is something I tried to do here: https://github.com/fballiano/openmage/pull/3

@fballiano
Copy link
Contributor

let's remove these lines and bump to 7.4, i'm fine with those

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

Successfully merging this pull request may close these issues.

5 participants