ubuntu 22.04 + Magento 2.4.7-beta1 + php8.2 + 3rd party app "Amasty" compilation error

165 Views Asked by At

I have a website (Magento 2.4.2 + php7.4) which runs well,then I upgraded it to (Magento 2.4.7-beta1 + php8.2) via composer, upgradtion succeeded,if the 3rd party app "Amasty" is removed from the project,"sudo php bin/magento setup:di:compile" ran well too; if the 3rd party app "Amasty" is kept on the project, "sudo php bin/magento setup:di:compile" got error: Compilation was started. Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 125.0 MiBPHP Fatal error: Cannot declare class Amasty\AdminActionsLog\lib\HtmlNode, because the name is already in use in /var/www/html/mydomain.com/app/code/Amasty/AdminActionsLog/lib/HtmlNode.php on line 6, note : line 6 content is "class HtmlNode {" below are 3 files of php partial source code among Amasty: (1) app\code\Amasty\AdminActionsLog\lib\HtmlNode.php

<?php
namespace Amasty\AdminActionsLog\lib;
include_once 'HtmlNodeText.php';
include_once 'HtmlSelector.php';
class HtmlNode {
    const NODE_ELEMENT = 0;

(2) app\code\Amasty\AdminActionsLog\lib\HtmlNodeCdata.php

<?php
namespace Amasty\AdminActionsLog\lib;
class HtmlNodeCdata extends HtmlNode {

(3) app\code\Amasty\AdminActionsLog\lib\HtmlNodeComment.php

<?php
namespace Amasty\AdminActionsLog\lib;
class HtmlNodeComment extends HtmlNode {

my question is : why "sudo php bin/magento setup:di:compile" ran well in php7.4 but got errors in php8.2 and how to fix it ?

thank you in advance.

1

There are 1 best solutions below

1
Kamil Bogdziewicz On

You have upgraded to the latest Magento, which is in beta. Amasty packages do not have support for this version. There is a change from PHP to a newer version, a lot of things may be outdated, some of the objects in Magento also get updates and it is required that you update the Amasty packages to a version that is compatible firstly with PHP8.2 and secondly with Magento in a newer version.

There is not much point in fixing this. I would ask the question in the other direction. Why do you want Magento in beta instead of choosing a stable version to which 3rd party packages may have already been updated?