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

Issue with PHP < 8.1 in composer.json #2378

Merged
merged 7 commits into from
Aug 10, 2022
Merged

Issue with PHP < 8.1 in composer.json #2378

merged 7 commits into from
Aug 10, 2022

Conversation

addison74
Copy link
Contributor

@addison74 addison74 commented Aug 7, 2022

In the composer.json file there is the following condition for the PHP version:

   "requires": {
     "php": ">=7.0 <7.5 || >=8.0 <8.1",

If you use Ubuntu 22.04 as a server, today the PHP version installed by default is 8.1.2. Running the command composer update will have the following negative effect:

screenshot

By changing the condition of the PHP version from 8.1 to 8.2, the composer update command will run without issues. The result is as follows:

ubuntu@ubuntu-virtual-machine:~/PhpstormProjects/magento-lts$ composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 10 updates, 0 removals
  - Upgrading symfony/console (v5.4.7 => v5.4.11)
  - Upgrading symfony/deprecation-contracts (v3.0.1 => v3.1.1)
  - Upgrading symfony/polyfill-ctype (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-intl-grapheme (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-intl-normalizer (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-mbstring (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php73 (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php80 (v1.25.0 => v1.26.0)
  - Upgrading symfony/service-contracts (v3.0.1 => v3.1.1)
  - Upgrading symfony/string (v6.0.3 => v6.1.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 17 installs, 0 updates, 0 removals
  - Downloading eloquent/enumeration (5.1.1)
  - Downloading justinrainbow/json-schema (5.2.12)
  - Downloading symfony/polyfill-mbstring (v1.26.0)
  - Downloading symfony/polyfill-intl-normalizer (v1.26.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.26.0)
  - Downloading symfony/polyfill-ctype (v1.26.0)
  - Downloading symfony/string (v6.1.3)
  - Downloading psr/container (2.0.2)
  - Downloading symfony/service-contracts (v3.1.1)
  - Downloading symfony/polyfill-php80 (v1.26.0)
  - Downloading symfony/polyfill-php73 (v1.26.0)
  - Downloading symfony/deprecation-contracts (v3.1.1)
  - Downloading symfony/console (v5.4.11)
  - Downloading flyingmana/composer-config-reader (20.0.1)
  - Downloading magento-hackathon/magento-composer-installer (4.0.2)
  - Downloading phpstan/phpstan (1.8.2)
  - Downloading macopedia/phpstan-magento1 (v1.0.4)
  - Installing eloquent/enumeration (5.1.1): Extracting archive
  - Installing justinrainbow/json-schema (5.2.12): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.26.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.26.0): Extracting archive
  - Installing symfony/string (v6.1.3): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing symfony/service-contracts (v3.1.1): Extracting archive
  - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive
  - Installing symfony/polyfill-php73 (v1.26.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.1.1): Extracting archive
  - Installing symfony/console (v5.4.11): Extracting archive
  - Installing flyingmana/composer-config-reader (20.0.1): Extracting archive
  - Installing magento-hackathon/magento-composer-installer (4.0.2): Extracting archive
you may want to add the packages.firegento.com repository to composer.
add it with: composer.phar config -g repositories.firegento composer https://packages.firegento.com
  - Installing phpstan/phpstan (1.8.2): Extracting archive
  - Installing macopedia/phpstan-magento1 (v1.0.4): Extracting archive
Generating autoload files
12 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
magento root dir "root" missing! create now? [Y,n] y
magento root dir "root" created
root/app/Mage.php is not a file.

This solves the issue related to php versions > 8.1
@github-actions github-actions bot added the composer Relates to composer.json label Aug 7, 2022
@elidrissidev
Copy link
Member

If we do this we have to make sure all compatibility issues with PHP 8.1 were resolved. @luigifab was working on a PR a long time ago but it was abandoned. I'm already using PHP 8.1 with OM 19 for a few months now and I'm not noticing any issues, but only locally and not in production.

As a side note if you don't know it already, you can ignore the PHP requirement with the flag --ignore-platform-req=php.

@addison74
Copy link
Contributor Author

I use version 8.1 from January in a test environment. I haven't faced any issues, but I haven't used OM fully to be able to say that 8.1 can be used. I think that the other versions are not 100% guaranteed either.

Obviously, we can use that flag but it must be mentioned in the README file considering that more and more new versions of operating systems provide PHP 8.1 packages, Ubuntu 22.04 is one of them. Whoever resumes Debian 10 or 11 does not have this issue because the first comes with PHP 7.3 and it has LTS until 2024, the second comes with PHP 7.4 and it has LTS until 2026. These two I am using in production.

Flyingmana
Flyingmana previously approved these changes Aug 8, 2022
Copy link
Contributor

@Flyingmana Flyingmana left a comment

Choose a reason for hiding this comment

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

approved, because we are close enough to supporting it.
There might still be issues, but we do not need to have fixed 100% of edge cases

@elidrissidev
Copy link
Member

composer.lock update is needed: composer update

@addison74
Copy link
Contributor Author

Here it is debated whether composer.lock should be deleted from repo #2341.

As a rule I run composer update command whether or not composer.lock file exists because in its content it represents a particular situation of the system in which it was generated.

If necessary I can add this file and I would make the modification manually in line 1271 without altering the content of the file.

@sreichel
Copy link
Contributor

sreichel commented Aug 8, 2022

I would make the modification manually in line 1271 without altering the content of the file.

Run composer update --lock should work, if you changed composer.json manually.

You can also run composer require php:">=7.0 <7.5 || >=8.0 <8.2" to update both files.

@sreichel
Copy link
Contributor

sreichel commented Aug 9, 2022

As a rule I run composer update command whether or not composer.lock file exists because in its content it represents a particular situation of the system in which it was generated.

No, not as a rule. (this is what #2341 is about)

Imho there are two points of view ...

Developer (this project here):

I dont want to have a composer.lock because i want to install it on every supported php version running composer install (not update).

From customer/end-user/agency view:

I want to have a commited composer.lock that matchs production/develop server and local environment for all devs. Also here i'd just use composer install when deploying and frequently commit dependency updates for all (composer update) or use something like https://github.com/dependabot to have latest compatible versions,

@sreichel
Copy link
Contributor

sreichel commented Aug 9, 2022

I use version 8.1 from January in a test environment. I haven't faced any issues,

Also https://github.com/PHPCompatibility/PHPCompatibility does only complain about a few things ... but nothing related to php8.1.

@fballiano
Copy link
Contributor

since composer.lock is on the repo as of this day it needs to be updated or all the workflows will fail

composer.json Outdated Show resolved Hide resolved
fballiano
fballiano previously approved these changes Aug 9, 2022
@fballiano fballiano self-requested a review August 9, 2022 20:32
@fballiano
Copy link
Contributor

composer build failed :-(

@elidrissidev
Copy link
Member

The change should preferably be done with command @sreichel posted, since it also recomputes the content-hash field in composer.lock (I suppose that's what's causing it to fail).

@addison74
Copy link
Contributor Author

Please check the new version of composer.lock file from my environment and let me know if it works.

@sreichel
Copy link
Contributor

sreichel commented Aug 9, 2022

My bad ... dependencies have been updated b/c missing flag --no-update?!?

@addison74
Copy link
Contributor Author

I propose to close this PR and let it be recreated by someone who uses Composer in OpenMage. I created it based on the error received in Ubuntu 22.04, but I am not able to operate everyone's requirements. The most important thing is that there is an issue and we must have a remedy and PHP is no longer limited to 8.1 nor has it passed 7.4.

@sreichel
Copy link
Contributor

sreichel commented Aug 9, 2022

If tests pass it should be okay.

Dependencies are now locked for 8.1 (latest version as @colinmollenhour suggested).

@addison74
Copy link
Contributor Author

What I did was to move the modified composer.json file to Ubuntu 22.04 and run the composer update command and it created the composer.lock file. The change that I operated must be verified by several people for this PR to be approved. If you make a comparison between the original and what I updated, the changes do not add anything. After running the command I did not receive any error message.

@sreichel
Copy link
Contributor

sreichel commented Aug 9, 2022

Difference between composer update and composer update --lock is, that first updates all dependencies, second adds just changes made to composer.json.

No special reviews required. As long the lock-file is there and test run with --ignore-platform... nothing changed?!?

@elidrissidev elidrissidev merged commit de186cc into OpenMage:1.9.4.x Aug 10, 2022
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
7 runs  ±0  5 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit de186cc. ± Comparison against base commit 8e5c460.

@addison74 addison74 deleted the ADDISON74-composer-json branch August 10, 2022 08:24
@addison74 addison74 mentioned this pull request Aug 10, 2022
sreichel added a commit that referenced this pull request Aug 12, 2022
* Merge PR #2342

* Revert "Add basic text for Ukraine (#2074)" (#2325)

This reverts commit 33dfa26.

* Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract: avoid loading all websites when using only the current one (#2351)

* Added support for HTTP2 to Mage_HTTP_Client_Curl (#1137)

* Blocked access to all dot files (#2349)

* Capitalization Adjustment Regarding CamelCase in Method Names (#2365)

* refactor: Adjusted capitalization of two public methods.

* refactor: Adjusted capitalization of one protected method.

* refactor: Adjusted capitalization of where call.

* chore: Removed fixed error from phpstan baseline.

* Some microoptimization (#2335)

* Avoid duplicate method calls

* Replaced array_push()

* Changed substr() third parameter

* Use array_key_exists()

* php7 opcode - internal functions

* Enclosed error with <pre> tag for prettier error print (if developer mode is enabled). (#2368)

* Updated phpstan to 1.8.2 (#2367)

* Escape product titles in MSRP JavaScript (#2366)

* Product names were not escaped. If contained a double quote, would break the JavaScript for MSRP/MAP

* update contribution list

* Update boxes.css (#2330)

* Force describeTable() to use read DB adapter (#2371)

* Do not install n98/n98_layouthelper (#2373)

* Add apt update to XML validation workflow (#2376)

* Merged PR #2375

* Replace remaining "sizeof" calls with "count" (#2369)

* Remove DISCLAIMER and change Magento -> OpenMage in header (#2297)

* Added label for phpstan cosmetic changes (#2384)

* Added weight to salesOrderShipmentAddTrack API (#1377)

* PHPStan/DOCBlock fixes (#2336)

* Updated docs for email addTo() (#2382)

* Updated phpstan experimental (#2386)

* Cosmetic changes to Mage_Payment_Model_Method_Abstract::validate() (#2388)

* Replaced join() calls with implode() (#2389)

* Hidden empty sub menu from backend (#2391)

* Remove Thumbs.db file (#2394)

* Support PHP 8.1 in composer.json (#2378)

* php condition in composer.json

This solves the issue related to php versions > 8.1

* Reduced condition for PHP requirement

* Changed PHP requirement

* Updated version in Ubuntu 22.04 based on PHP 8.1.2

* Composer.lock updated in Ubuntu 20.04 (PHP 8.1.2)

* Update composer.lock

* Update composer.lock

* Blocked various file types in .htaccess (#2359)

* Color swatches work with disparate product IDs (#2390)

* Move Credit Memo at the end of the buttons list (#2392)

* Version bump (#2387)

* Minor fixes on 'filter_condition_callback' method _filterStoreCondition() (#2362)

* add ReturnTypeWillChange to various Files catched by code style checker #2302

* Phpstan fixes (#2396)

* Fixed addCrumb()

* Fixed initForm() and _needToAddDummy()

* Fixed addLink()

* Fixed addLinkRel()

* Fixed canUseCanonicalTag()

* Fixed getAddUrl...()

* Fixed rollBack() camelCase error reported by phpstan (#2403)

* Changes default root dir in composer.json (#2401)

* Fixed targetNamespace for WS-I Compliant SOAP APIs (#2405)

* Updated phpstan baseline

Co-authored-by: sv3n <[email protected]>
Co-authored-by: Fabian Blechschmidt <[email protected]>
Co-authored-by: Colin Mollenhour <[email protected]>
Co-authored-by: Kevin Jakob <[email protected]>
Co-authored-by: Ng Kiat Siong <[email protected]>
Co-authored-by: Scott Moore <[email protected]>
Co-authored-by: ADDISON <[email protected]>
Co-authored-by: Justin Beaty <[email protected]>
Co-authored-by: luigifab <[email protected]>
Co-authored-by: Daniel Fahlke <[email protected]>
Co-authored-by: leissbua <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
composer Relates to composer.json
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants