0

After doing an update from 2.4.2 to 2.4.6 I am getting that error on compilation in compilation step 5 rfunning PHP 8.1. I searched a bit and found setup:di:compile fails after update to magento 2.4.4. I applied this solution, which gives me another error in compilation step 3:

Cannot use isset() on the result of an expression

So, any idea how to solve this problem?

Thanks!

5
  • 1
    What is the full error stack trace? I don't know what steps 3 and 5 you are referring to. Try to add verbose argument to your bin/magento command to get verbose output, eg: bin/magento setup:di:compile -vvv. And what is your PHP version?
    – Tu Van
    Apr 24 at 8:30
  • I added -vvv and the result is: pastebin.com/uxVJfvb9 Added the other information in my post...thanks for helping! Apr 24 at 8:41
  • The Pastebin link is not found, could you check it out?
    – Tu Van
    Apr 24 at 8:42
  • Sure? Works for me, tried in different browsers... Apr 24 at 8:43
  • I can access it now, somehow Patebin denies my IP.
    – Tu Van
    Apr 24 at 8:44

1 Answer 1

1

I'll try to help you debug here. Firstly, let's revert your change in line 171.
Then try to remove generated directory and cache directories too and run bin/magento setup:upgrade to make sure that anything related to this issue is cleared:

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf generated/*
bin/magento setup:upgrade

And recompile code with verbose argument:

bin/magento setup:di:compile -vvv

If the issue still persists, let's open setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php, and edit line 125 to dump the value of $configuredArgument variable which passes to getConfiguredInstanceArgument(array $config) method - line 171

Replace $argument = $this->getConfiguredInstanceArgument($configuredArgument); with

var_dump($configuredArgument);
$argument = $this->getConfiguredInstanceArgument($configuredArgument);

Run bin/magento setup:di:compile and check the result, if it's long lines result, paste it somewhere which allows sharing long lines of code like pastebin, and share it here. If it works properly, it should output something similar to this:

Compilation was started.
Area configuration aggregation... 5/9 [===============>------------]  55% 39 secs 390.0 MiBarray(1) {
  ["instance"]=>
  string(40) "Magento\Framework\Filesystem\Driver\File"
}
array(1) {
  ["instance"]=>
  string(37) "Magento\Backend\Block\MenuItemChecker"
}
array(1) {
  ["instance"]=>
  string(36) "Magento\Backend\Block\AnchorRenderer"
}
array(1) {
  ["instance"]=>
  string(46) "Magento\Config\Model\ResourceModel\Config\Data"
}
array(1) {
  ["instance"]=>
  string(63) "Magento\Config\Model\ResourceModel\Config\Data\Collection\Proxy"
}

Update: Output from OP's command:

array(1) {
  ["instance"]=>
  string(43) "Magento\Shipping\Model\Method\VirtualLogger"
}
array(1) {
  ["instance"]=>
  string(46) "Magento\Config\Model\ResourceModel\Config\Data"
}
array(1) {
  ["instance"]=>
  string(63) "Magento\Config\Model\ResourceModel\Config\Data\Collection\Proxy"
}
array(1) {
  ["instance"]=>
  string(46) "Magento\Config\Model\ResourceModel\Config\Data"
}
array(1) {
  ["instance"]=>
  string(63) "Magento\Config\Model\ResourceModel\Config\Data\Collection\Proxy"
}
array(1) {
  ["instance"]=>
  string(43) "Magento\Shipping\Model\Method\VirtualLogger"
}
array(1) {
  ["instance"]=>
  string(46) "Magento\Variable\Model\Config\StructureVirtual"
}
array(1) {
  ["general/imprint"]=>
  array(33) {
    ["general/imprint/shop_name"]=>
    string(1) "1"
    ....
  }
}

Based on your output, the last item doesn't have instance node which caused the error.
The config indicates you are using FireGento MageSetup module and I guess you are still at an older version. They reported the error for Magento 2.4.3 and fixed it 2 years ago. https://github.com/firegento/firegento-magesetup2/pull/200/files#diff-093a1e43a11122404c853506b7ca4f661e18dd4f6557ec3089cad8ceae34a606

So, to resolve your issue, edit <FireGento_MageSetup module dir>/etc/di.xml to replace

<type name="Magento\Variable\Model\Source\Variables">

with

<type name="Magento\Variable\Model\Config\Structure\AvailableVariables">

or upgrade the FireGento MageSetup module to the latest version.

Read more about the FireGento MageSetup module at https://github.com/firegento/firegento-magesetup2

5
  • Thanks! I added the suggested change to line 125 and this is the output: pastebin.com/XdkPzb5N. Thanks! Apr 24 at 12:35
  • Could you confirm you have done above steps before modify ArgumentsResolver.php file? I’m checking your output.
    – Tu Van
    Apr 24 at 12:53
  • I've found the root cause of the issue and added the solution to my answer, please check.
    – Tu Van
    Apr 24 at 16:03
  • 1
    Thanks man, that solved it, it was the MageSetup extension :-)! Apr 25 at 6:30
  • @user4095519 Cool, glad to help!
    – Tu Van
    Apr 25 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.