View Issue Details

IDProjectCategoryView StatusLast Update
0017270mantisbtbugtrackerpublic2014-12-08 02:08
Reporterdregad Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.0dev 
Target Version1.3.0-beta.1 
Summary0017270: PHP Deprecated, Warnings and Notices kill CLI scripts
Description

I noticed while running PHPunit tests on PHP 5.5 that the script aborts after displaying a message when it encounters a non-critical error.

Furthermore, the exit code is 0, so in the case of test scripts, they are considered successful despite not having run at all.

Steps To Reproduce

Setup mantis with 'mysql' driver, then


cd /path/to/mantis/tests
phpunit --bootstrap bootstrap.php Mantis/HelperTest.php

Error displayed:


mysql_connect(): The mysql extension is deprecated [...]

TagsNo tags attached.

Activities

dregad

dregad

2014-05-02 10:47

developer   ~0040201

The problem was introduced by commit 461a7115. The idea was to display "clean" error messages (i.e. without HTML formatting) when running command-line scripts, but then an exit() statement is issued regardless of the state of $g_display_errors causing a failure due to an E_DEPRECATED notice.

This code needs rework, will submit a pull request later.

dregad

dregad

2014-05-04 04:45

developer   ~0040209

Pull request https://github.com/mantisbt/mantisbt/pull/174

dregad

dregad

2014-05-04 04:59

developer   ~0040210

Testing

  • $g_display_errors = array ( E_ALL => 'inline' ); - OK, execution aborts


    DEPRECATED: 'mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead' in '/home/dregad/dev/mantisbt/library/adodb/drivers/adodb-mysql.inc.php' line 458

  • $g_display_errors = array ( E_ALL => 'inline' ); - OK, message display, execution continues


    DEPRECATED: 'mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead' in '/home/dregad/dev/mantisbt/library/adodb/drivers/adodb-mysql.inc.php' line 458
    PHPUnit 3.7.28 by Sebastian Bergmann.

.......

Time: 127 ms, Memory: 10.75Mb

OK (7 tests, 7 assertions)

  • standard config_inc.php settings ($g_display_errors defaults to 'none') - OK, no message, execution continues

Related Changesets

MantisBT: master 461a7115

2014-01-05 11:52

Paul Richards


Details Diff
If an error occurs, and we are running from the client sapi api, just display the raw error on a new line and do not attempt to add any html formatting Affected Issues
0017270
mod - core/error_api.php Diff File

MantisBT: master 167ca0f6

2014-05-12 03:51

dregad


Details Diff
Improve error handling for command-line scripts

Commit 461a7115d37de79e4875b651edd10fd556a533c3 added CLI-specific
handling for errors to display messages without HTML formatting.

This introduced a regression, causing scripts to abort even for
non-critical errors that would normally allow execution to continue
(such as PHP warnings as well as system and deprecated notices).
Furthermore, in that case the exit code is 0, so the caller is not able
to detect the failure to take appropriate action.

This improves how CLI errors are managed, making it similar to regular
MantisBT error handling, i.e.
- honor $g_display_errors settings
- abort only for DISPLAY_ERROR_HALT (in that case exit code is 1)
- don't print message if DISPLAY_ERROR_NONE
- handle E_DEPRECATED error type
- improve message for unhandled error types
- print a debug backtrace when show_detailed_errors == ON

Fixes 0017270
Affected Issues
0017270
mod - core/error_api.php Diff File