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.56k stars 9.32k forks source link

Unable to turn on MAGE_PROFILER dependency graphs (MAGE_PROFILER 2) #27459

Open duxabilii opened 4 years ago

duxabilii commented 4 years ago

Preconditions (*)

  1. Magento 2.3.3, Magento 2.3.4
  2. Magento 2.4-develop

Steps to reproduce (*)

  1. Enable profiler dependency graphs via .htaccess adding SetEnv MAGE_PROFILER 2

Expected result (*)

  1. Dependency graphs displayed at the bottom of a page.

Actual result (*)

  1. PHP Fatal Error Fatal error: Declaration of Magento\Framework\App\Request\PathInfo\Logger::getPathInfo(string $requestUri, string $baseUrl) must be compatible with Magento\Framework\App\Request\PathInfo::getPathInfo(string $requestUri, string $baseUrl): string in /var/www/generated/code/Magento/Framework/App/Request/PathInfo/Logger.php on line 0
m2-assistant[bot] commented 4 years ago

Hi @duxabilii. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@duxabilii do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


duxabilii commented 4 years ago

I have the same issue on Magento dev-2.4-develop

perryholden commented 4 years ago

This is interesting. Per Magento DevDocs article Enable profiling (MAGE_PROFILER), the numeric options are still supported, but it has to be deprecated somehow. Basically, what is happening is that when this env variable is set to "2", the \Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger ultimately gets called to create a wrapper for each instance of a class that is instantiated by the ObjectManager, so that these classes may be profiled too.

Thing is, this generator class (again, which is used to generate the additional logger classes to be stored in generated\code) isn't smart enough to deal with the new return types used in PHP 7. In your specific instance, the original class wants a return type of : string, which the generated class does not have.

You can configure \Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger::_getMethodInfo to take the return type into account (because laminas/laminas-code, which is used to generate the new logger class can generate classes with a return type), but this then in turn reveals a whole lot more that is broken.

I won't go into all the details, but the "invoke" method created by that generator class doesn't deal well with methods that return void, for instance, plus it also creates constructors that totally conflict with the classes they are overriding.

In short: this is completely broken, primarily because it's never been updated to deal with PHP 7 and their return types. I wish someone at Magento could indicate whether or not this is abandoned, or is just an oversight. Perhaps Blackfire is causing this to never be used and not be missed?

m2-assistant[bot] commented 4 years ago

Hi @engcom-Delta. 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:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Delta Thank you for verifying the issue. Based on the provided information internal tickets MC-38977 were created

Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.