PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Testing » PHPUnit2 » Bug #7373

Unexpected "syntax error" in safe mode

Details

Submitted2006-04-12 06:37 UTC
Fromdoctor at wil dot linux dot krakow dot pl
Assignedsebastian
StatusClosed
PackagePHPUnit2
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2006-04-12 06:37 UTC] doctor at wil dot linux dot krakow dot pl

Description:
------------
I used to develop my programs with all that safe mode restrictions turned on. It makes me sure that it'll work on every host, that software is little more secure and so on.

While in safe mode I'm getting following output:

---console---
Warning: shell_exec(): Cannot execute using backquotes in Safe Mode in E:\PEAR\PHPUnit2\Util\Fileloader.php on line 86
PHPUnit 2.3.5 by Sebastian Bergmann.

Syntax error in E:\PEAR\ArrayTest.php
-------------

OK then. It's a bit frustrating message because there's no syntax error in ArrayTest.php. The error occurs because shell_exec won't execute 'php -l' in safe mode. Thanks to this $output='' and everything fails.

Test script:
---------------
Fileloader.php, begining at line 86:
-----
$output = shell_exec('php -l ' . escapeshellarg($filename));

if (strpos($output, 'No syntax errors detected in') === FALSE) {
throw new Exception(
sprintf(
'Syntax error in %s.',

str_replace('./', '', $filename)
)
);
}

Expected result:
----------------
I whish the script let it go even if it couldn't check the syntax. Changing condition solves the problem:

Fileloader.php, line 88:
-----
if (strpos($output, 'Errors parsing') === TRUE) {
-----

However I don't know if is it necessary to check syntax at all, since the php parser will trigger such errors itself.

Actual result:
--------------
In safe mode shell_exec won't execute so $output=''. Then the condition passes and exception is thrown.

[2006-06-01 07:16 UTC] sebastian at php dot net

This bug has been fixed in CVS.

If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

Fixed for PHPUnit 3.0, sorry this took so long.

[2006-06-30 15:54 UTC] slsoek at yahoo dot com

shell_exec():
Is there away to not using cmd.
Because windows is shutting down any calls from web to cmd.exe.
shell_exec() is one of the functions that is using cmd.exe.
PHP
IIS6
Windows 2003 and greater