theseer / phpdox

Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)
http://phpdox.de
Other
600 stars 121 forks source link

Problem disabling xdebug #409

Closed splitbrain closed 3 years ago

splitbrain commented 3 years ago

When I try to run the latest phar, the tool crashes with the following output. Seems like it tries to execute xdebug_disable within the phpDox namespace!?

phpDox 0.12.0 - Copyright (C) 2010 - 2021 by Arne Blankerts and Contributors

Oups... phpDox encountered a problem and has terminated!

It most likely means you've found a bug, so please file a report for this
and paste the following details and the stacktrace (if given) along:

PHP Version: 7.4.15 (Linux)
PHPDox Version: 0.12.0
Exception: Error (Code: 0)
Location: phar:///home/andi/www/devel/slika/phpdox-0.12.0.phar/phpdox/shared/Environment.php (Line 46)

Call to undefined function TheSeer\phpDox\xdebug_disable()

#0 phar:///home/andi/www/devel/slika/phpdox-0.12.0.phar/phpdox/CLI.php(50): TheSeer\phpDox\Environment->ensureFitness()
#1 /home/andi/www/devel/slika/phpdox-0.12.0.phar(485): TheSeer\phpDox\CLI->run()

I'm running xdebug 3.0.2 BTW.

theseer commented 3 years ago

Yes, that's because Derick removed xdebug_disable in 3.x and phpDox doesn't know about that yet.

While with Xdebug 3.x the performance penalty even when not actively using it is almost gone, it's always a good idea to not have extensions loaded you don't need. As a temporary workaround, just remove xdebug from your cli environment as it will slow down execution in worstcase or be uselessly loaded at best.

I will try to make a new release sometime soon but phpDox sadly suffers under neglect and I don't have much time these days to work on it.

KatharinaSt commented 3 years ago

Yes, that's because Derick removed xdebug_disable in 3.x and phpDox doesn't know about that yet.

The check itself is not the problem here.

The issue is that if the function exists in the global namespace it is not executed as xdebug_disable() but as TheSeer\phpDox\xdebug_disable() instead.

I suppose a simple backslash could help here \xdebug_disable() but I currently can't test it.

theseer commented 3 years ago

Yes, that's because Derick removed xdebug_disable in 3.x and phpDox doesn't know about that yet.

The check itself is not the problem here.

The issue is that if the function exists in the global namespace it is not executed as xdebug_disable() but as TheSeer\phpDox\xdebug_disable() instead.

I suppose a simple backslash could help here \xdebug_disable() but I currently can't test it.

Actually, yes and no: In xdebug 3.x, there simply is no xdebug_disable() function. That's why PHP is trying to use a "local" variant. But prepending a \ won't change the fact the function doesn't exist - it would merely fail with complaining \xdebug_disable not defined, rather than TheSeer\phpDox\xdebug_disable not defined.

The check is simply wrong. It needs to check if xdebug is enabled and the function exists. I just don't have time for phpDox these days. Sorry for the delay...

KatharinaSt commented 3 years ago

Thank you for the clarification and sorry for the misunderstanding! Now I understand where I have been wrong! 🤦‍♀️

I thought we were actually talking about this but that is already the fixed variant (which only is in the master by now and just not yet in a current release):

        if (function_exists('xdebug_disable')) {
            xdebug_disable();
        }

Have a nice weekend!

theseer commented 3 years ago

The underlying issue is fixed. I'll to make a reason soon.