Skip to content

Commit

Permalink
fix: PHP8.1 Builds for M2.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SamJUK committed Nov 7, 2024
1 parent 35909db commit d06aa0b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 26 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/magento-2.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,56 +88,54 @@ jobs:
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.5-p1, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.5, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.5, SAMPLE_DATA: true }
# 2.4.4 + 8.1 is disabled due to this bug:
# https://github.com/magento/magento2/issues/35292
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p11, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p10, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p9, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p8, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p7, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p6, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p5, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p4, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p3, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p2, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4-p1, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: true }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: false }
# - { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: true }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: false }
- { PHP_VERSION: php81-fpm, MAGENTO_VERSION: 2.4.4, SAMPLE_DATA: true }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.3-p2, SAMPLE_DATA: false }
- { PHP_VERSION: php74-fpm, MAGENTO_VERSION: 2.4.3-p2, SAMPLE_DATA: true }
- { PHP_VERSION: php73-fpm, MAGENTO_VERSION: 2.4.3-p1, SAMPLE_DATA: false }
Expand Down
2 changes: 2 additions & 0 deletions magento/Dockerfile-2.4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY scripts/apply-2.4-patches.php scripts/apply-2.4-patches.php
COPY scripts/downgrade-monolog.php scripts/downgrade-monolog.php
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
COPY scripts/remove-paypal-braintree.php scripts/remove-paypal-braintree.php
COPY scripts/patch-AC2855.php scripts/patch-AC2855.php
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini

RUN ./start-services && \
Expand All @@ -29,6 +30,7 @@ RUN ./start-services && \
composer config --unset repositories.0 && \
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/ && \
./retry "composer install" && \
php scripts/patch-AC2855.php && \
php scripts/downgrade-monolog.php && \
php scripts/remove-paypal-braintree.php && \
if [ -f "/data/vendor/magento/module-inventory-catalog/etc/communication.xml" ]; then sed -i 's/is_synchronous="false"//g' /data/vendor/magento/module-inventory-catalog/etc/communication.xml; fi && \
Expand Down
61 changes: 61 additions & 0 deletions magento/patches/AC2855.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --git a/vendor/magento/framework/Code/Generator/EntityAbstract.php b/vendor/magento/framework/Code/Generator/EntityAbstract.php
index 35a0bff..10fd3f7 100644
--- a/vendor/magento/framework/Code/Generator/EntityAbstract.php
+++ b/vendor/magento/framework/Code/Generator/EntityAbstract.php
@@ -10,6 +10,8 @@ use Magento\Framework\GetParameterClassTrait;

/**
* Abstract entity
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
abstract class EntityAbstract
{
@@ -18,7 +20,7 @@ abstract class EntityAbstract
/**
* Entity type abstract
*/
- const ENTITY_TYPE = 'abstract';
+ public const ENTITY_TYPE = 'abstract';

/**
* @var string[]
@@ -332,14 +334,22 @@ abstract class EntityAbstract
/** @var string|null $typeName */
$typeName = null;
$parameterType = $parameter->getType();
- if ($parameterType->getName() === 'array') {
+
+ if ($parameterType instanceof \ReflectionUnionType) {
+ $parameterType = $parameterType->getTypes();
+ $parameterType = implode('|', $parameterType);
+ } else {
+ $parameterType = $parameterType->getName();
+ }
+
+ if ($parameterType === 'array') {
$typeName = 'array';
} elseif ($parameterClass = $this->getParameterClass($parameter)) {
$typeName = $this->_getFullyQualifiedClassName($parameterClass->getName());
- } elseif ($parameterType->getName() === 'callable') {
+ } elseif ($parameterType === 'callable') {
$typeName = 'callable';
} else {
- $typeName = $parameterType->getName();
+ $typeName = $parameterType;
}

if ($parameter->allowsNull()) {
diff --git a/vendor/magento/framework/Interception/Code/Generator/Interceptor.php b/vendor/magento/framework/Interception/Code/Generator/Interceptor.php
index 43e9d97..c363f80 100644
--- a/vendor/magento/framework/Interception/Code/Generator/Interceptor.php
+++ b/vendor/magento/framework/Interception/Code/Generator/Interceptor.php
@@ -72,7 +72,7 @@ class Interceptor extends EntityAbstract
$reflectionClass = new \ReflectionClass($this->getSourceClassName());
$publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($publicMethods as $method) {
- if ($this->isInterceptedMethod($method)) {
+ if (!$method->isInternal() && $this->isInterceptedMethod($method)) {
$methods[] = $this->_getMethodInfo($method);
}
}
21 changes: 21 additions & 0 deletions magento/scripts/patch-AC2855.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php

$version = getenv('MAGENTO_VERSION');
$is244 = substr($version, 0, 5) == '2.4.4';
$patchLevel = (int)substr($version, 7);

if (!$is244 || $patchLevel > 100) {
echo 'AC2855 Breaking bug does not exist in this version' . PHP_EOL;
exit(0);
}

$output = null;
$code = null;
exec('cd /data && patch -p1 < patches/AC2855.patch', $output, $code);

if ($code !== 0) {
echo 'Error applying patch for AC2855' . PHP_EOL;
echo implode(PHP_EOL, $output);
exit($code);
}

0 comments on commit d06aa0b

Please sign in to comment.