magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.46k stars 9.29k forks source link

PHP 8.2/8.3, only one dependency fails the php linter at the moment: league/flysystem #38415

Closed hostep closed 2 days ago

hostep commented 7 months ago

Preconditions and environment

Steps to reproduce

  1. Clone magento repo with 2.4-develop branch.
  2. Also setup the dev versions of the inventory, security-package & pagebuilder repo's in the ext/ subdir according to their installation guides.
  3. Run composer update with PHP 8.3 so all packages are at the latest version
  4. Now, with all files in place, let's run all php files through the php linter:
    $ find . -type f -iname '*.phtml' -exec php83 -l {} + | grep -v 'No syntax errors detected'
    $ find . -type f -iname '*.php' -exec php83 -l {} + | grep -v 'No syntax errors detected'

    (note that my PHP 8.3 binary is called php83, replace it in the commands above with the one from your own setup. Also note that I'm making use of {} + syntax which is a new feature of PHP 8.3: It is now possible to lint multiple files, so don't attempt this with lower PHP versions (with lower PHP versions you'd need the {} \; syntax which will run many times slower))

Expected result

No linting errors found

Actual result

2 linting errors found in league/flysystem package:

PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in ./vendor/league/flysystem/src/UnableToCreateDirectory.php on line 19

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in ./vendor/league/flysystem/src/UnableToCreateDirectory.php on line 19
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in ./vendor/league/flysystem/src/UnableToCheckFileExistence.php on line 14

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in ./vendor/league/flysystem/src/UnableToCheckFileExistence.php on line 14

Additional information

This has been fixed in league/flysystem version 3.0.20 with this commit: https://github.com/thephpleague/flysystem/commit/c327a6ead673031186f38411ce9b72b8672a1596

But Magento still requires version 2 of the 2 league/flysystem packages: https://github.com/magento/magento2/blob/984630670aa9ffb711b3169f1c1a15ea5cc4f052/composer.json#L69-L70 Updating them to version 3 should make the entire codebase of Magento Open Source compatible with PHP 8.2/8.3 (at least for the basic php linting check, there might still be other runtime bugs around, but those are harder to detect)

Maybe some important info can be found in this blog post around flysystem v3...

Release note

No response

Triage and priority

m2-assistant[bot] commented 7 months ago

Hi @hostep. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

hostep commented 7 months ago

Extra note, to setup those 3 extra packages using composer, you'll need these changes in the composer.json:

diff --git a/composer.json b/composer.json
index 6260fa5192c..47da42c7c98 100644
--- a/composer.json
+++ b/composer.json
@@ -45,13 +45,12 @@
         "guzzlehttp/guzzle": "^7.5",
         "laminas/laminas-captcha": "^2.17",
         "laminas/laminas-code": "^4.13",
-        "laminas/laminas-di": "^3.13",
-        "laminas/laminas-file": "^2.13",
         "laminas/laminas-db": "^2.15",
-        "laminas/laminas-oauth": "^2.6",
+        "laminas/laminas-di": "^3.13",
         "laminas/laminas-escaper": "^2.13",
         "laminas/laminas-eventmanager": "^3.11",
         "laminas/laminas-feed": "^2.22",
+        "laminas/laminas-file": "^2.13",
         "laminas/laminas-filter": "^2.33",
         "laminas/laminas-http": "^2.15",
         "laminas/laminas-i18n": "^2.17",
@@ -59,6 +58,7 @@
         "laminas/laminas-mime": "^2.9",
         "laminas/laminas-modulemanager": "^2.11",
         "laminas/laminas-mvc": "^3.6",
+        "laminas/laminas-oauth": "^2.6",
         "laminas/laminas-permissions-acl": "^2.10",
         "laminas/laminas-server": "^2.16",
         "laminas/laminas-servicemanager": "^3.16",
@@ -70,7 +70,10 @@
         "league/flysystem-aws-s3-v3": "^2.4",
         "magento/composer": "dev-develop",
         "magento/composer-dependency-version-audit-plugin": "^0.1",
+        "magento/inventory-metapackage": "1.2.0-dev",
         "magento/magento-composer-installer": ">=0.4.0",
+        "magento/page-builder": "dev-develop",
+        "magento/security-package": "dev-develop",
         "magento/zend-cache": "^1.16",
         "magento/zend-db": "^1.16",
         "magento/zend-pdf": "^1.16",
@@ -400,5 +403,25 @@
             "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
         }
     },
-    "prefer-stable": true
+    "prefer-stable": true,
+    "minimum-stability": "dev",
+    "repositories": {
+        "ext_pb": {
+            "type": "path",
+            "url": "./ext/*/*/*/*/*/*"
+        },
+        "ext_sec": {
+            "type": "path",
+            "url": "./ext/*/*/*"
+        },
+        "ext_inv": {
+            "type": "path",
+            "url": "./ext/*/*/*"
+        },
+        "magento": {
+            "type": "vcs",
+            "url": "https://github.com/magento/inventory-composer-installer.git",
+            "only": ["magento/inventory-composer-installer"]
+        }
+    }
 }
m2-assistant[bot] commented 7 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 7 months ago

Hello @hostep,

Thank you for the report!

Verified this issue on 2.4-develop. With php version 8.3, while running the linter as mentioned we were able to get the actual result.

image

Hence confirming the issue.

Thank you.

github-jira-sync-bot commented 7 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10971 is successfully created for this GitHub issue.

m2-assistant[bot] commented 7 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

engcom-Charlie commented 6 months ago

Hi @hostep,

Internal team has started working on the issue. We are working on related issue AC-10721 “league/flysystem” Composer dependencies upgrading to latest version as well as a separate request and we are planning to deliver the current AC-10971 issue with this one.

We will update about the progress. Thank you.

engcom-Bravo commented 2 months ago

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-10971 by the internal team Related commits: https://github.com/magento/magento2/commit/91cb4d46834b88bb8dc9f5b06279a63d9ad0963c

Based on the Jira ticket, the target version is 2.4.8-beta1.

Thanks

hostep commented 2 months ago

Thanks guys!

engcom-Charlie commented 2 months ago

As we observed performance issue with functional build after merging the changes mentioned in above comment, we have reverted the changes. Will get back with latest update sooner. Till then reopening the issue.

m2-assistant[bot] commented 2 months ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 months ago

Since the issue is not yet resolved and has already been confirmed, I am re-adding the confirmed label.

github-jira-sync-bot commented 2 months ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-10971

hostep commented 2 days ago

Seems like it got fixed by AC-10971::PHP 8.2/8.3, only one dependency fails the php linter at the moment: league/flysystem

Thanks guys!

engcom-Bravo commented 2 days ago

@hostep Thanks for your contribution!!.

As I can see this issue got fixed in the scope of the internal Jira ticket AC-10971 by the internal team Related commits:https://github.com/search?q=repo%3Amagento%2Fmagento2+AC-10971&type=commits

Based on the Jira ticket, the target version is 2.4.8-beta1.

Thanks