magento/magento2-functional-testing-framework

Magento fails with xdebug 3 due to mftf

kandy opened this issue ยท 21 comments

kandy commented

Preconditions

  1. Install xdebug 3 (RC1+) and enable it

Steps to reproduce

  1. Run bin/magento

Expected result

  1. List of available command is printed

Actual result

PHP Fatal error:  Uncaught Error: Call to undefined function xdebug_disable() in /magento/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php:81
Stack trace:
#0 /magento/vendor/composer/autoload_real.php(73): require()
#1 /magento/vendor/composer/autoload_real.php(63): composerRequire4012c480a3949eb57e5b1ec1b7b5c42b('eda65932675b68b...', '/magento/vendor...')
#2 /magento/vendor/autoload.php(7): ComposerAutoloaderInit4012c480a3949eb57e5b1ec1b7b5c42b::getLoader()
#3 /magento/app/autoload.php(51): include('/magento/vendor...')
#4 /magento/app/bootstrap.php(33): require_once('/magento/app/au...')
#5 /magento/bin/magento(14): require('/magento/app/bo...')
#6 {main}
  thrown in /magento/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php on line 81

see for details https://3.xdebug.org/docs/upgrade_guide

Hi @kandy. Thank you for your report.
To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


jilu1 commented

@kandy Thank you for your report!
https://jira.corp.magento.com/browse/MQE-2391 has been created. Please check comments in MQE-2391 and let us know if this needs immediate attention.

A bunch of our test suites started failing in travis because of this error.

I think travis has likely started bundling xdebug 3 or something like that.

before_install:
  - phpenv config-rm xdebug.ini || true

I have slipped this into our .travis.yml and the suites are running again.

jilu1 commented

@convenient It's good to know you have a solution!
If your problem is the same as this xdebug_disable() in _bootstrap.php, it's been fixed and available in develop branch. No planned release date yet.

@tuyennn I think these are the two commits you asked for:

e95fb10
6d6a7c5

Please, correct me, if I'm wrong.

@densen45 @jilu1 hopefully the release could start soon

xdebug_disable is only called if both MFTF debugging is disabled and the Xdebug module is loaded.
Its possible to enable MFTF debugging by adding/editing the file dev/tests/acceptance/.env and adding the line MFTF_DEBUG = 1
I've done this in my dev environment, but as I don't understand the consequences of enabling MFTF debugging I have not enabled it in my production environment. However, as I don't have Xdebug installed in my production environment, this is not an issue.

@jilu1 @kandy Pls Realse ASAP most Partners use Integration,Static, Mftf Tests on CI-System and Local all our tests are RED beausce of this issue. Build Patch for us and need to apply them now to all our customers

Not only bin/magento fails, also web requests crash with xdebug 3. Which means that it's impossibile to debug web requests with xdebug 3

@azambon Yea because most thinks runs over this _bootstrap.php in dev mode ๐Ÿ˜…

We created a Patch for our vendor folder fixed all problems for us:
e95fb10

From e95fb10d3a55d72af5d60e07703d09201812599e Mon Sep 17 00:00:00 2001
From: Ji Lu <jilu1@adobe.com>
Date: Wed, 18 Nov 2020 12:18:26 -0600
Subject: [PATCH] MQE-2391: [GitHub Issue] Magento fails with xdebug 3
---
--- vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php
+++ vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php
@@ -77,6 +77,3 @@
 
 // add the debug flag here
 $debugMode = $_ENV['MFTF_DEBUG'] ?? false;
-if (!(bool)$debugMode && extension_loaded('xdebug')) {
-    xdebug_disable();
-}

vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php

Replace:

if (!(bool)$debugMode && extension_loaded('xdebug')) {
    xdebug_disable();
}

By:

if (!(bool)$debugMode && extension_loaded('xdebug')) {
    if (function_exists('xdebug_disable')) {
        xdebug_disable();
    }
}
jilu1 commented

@larsroettig @tuyennn @lfluvisotto Thanks for the information! We will try to release a patch soon.

Would be so nice thanks in advance ๐Ÿ‘

@lfluvisotto you dont need open a PR is already fixed but not released

jilu1 commented

Here is the fix, please let us know if you see any other issue.
f99fbbc

Here is the fix, please let us know if you see any other issue.
f99fbbc

This fix works fine for us

Here is the fix, please let us know if you see any other issue.
f99fbbc

after this fix xdebug is not working on that project ๐Ÿ˜ž

jilu1 commented

@Lmarcho
Could you provide more details?

The fix is not to disable xdebug and I don't think it will affect how xdebug works.

jilu1 commented

This is now available in 3.2.1

Working Solution :

Open xdebug.ini in your favorite Editor

Add These Lines

xdebug.mode=debug
xdebug.client_port=9000

Your Debugger will start Working