appserver-io / appserver

A multithreaded application server for PHP, written in PHP.
http://appserver.io/
Open Software License 3.0
965 stars 104 forks source link

DOPPELGAENGER process fails to handle spaces between function and the function name #1121

Closed jefkin closed 5 years ago

jefkin commented 5 years ago

DOPPELGAENGER process fails to handle additional spaces between the 'function' keyword and the function name.

Worse, this is a silent failure at startup, appearing to be a good setup for the app, but leading to 500 errors on access to the app servlets like: exception 'AppserverIo\Psr\Servlet\ServletException' with message 'Please configure an error page for status code 500' in /opt/appserver/src/AppserverIo/Appserver/ServletEngine/Utils/ErrorUtil.php:291 Stack trace:

0 /opt/appserver/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php(263): AppserverIo\Appserver\ServletEngine\Utils\ErrorUtil->handleErrors(Object(AppserverIo\Appserver\ServletEngine\RequestHandler),

Object(AppserverIo\Appserver\ServletEngine\Http\Request), Object(AppserverIo\Appserver\ServletEngine\Http\Response))

1 [internal function]: AppserverIo\Appserver\ServletEngine\RequestHandler->shutdown()

2 {main}

The PHP error log reports: [09-May-2019 15:44:53 Europe/Berlin] PHP Fatal error: Cannot redeclare \\::doGet() in /opt/appserver/var/tmp/localhost//cache/.php on line 85

Examining the cached file, in comparison to other working class files revealed that there were two entries for doGet, the original one (WITHOUT the DOPPELGAENGEROriginal suffix) and the one created by the Doppelgaenger process.

Probably the issue here is two fold:

  1. The Doppelgaenger process doesn't match the original function name (probably a regex issue, if I were to be assumptive)
  2. The Doppelgaenger process doesn't catch the situation in which the above matching failed, leaving the code in a bad state with duplicate method names.
wick-ed commented 5 years ago

Hi @jefkin

thanks for reporting the bug!

Your assumption was correct, there are a sub-optimal regex in use within the function substitution logic. The issue will be fixed with release 1.7.3 of the doppelgaenger library.

Best regards, Bernhard