Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep. 06, 2010, 04:08:59 PM
53852 Posts in 11999 Topics by 11436 Members
Latest Member: clod
News:
 
The PRADO Community » Prado v3.x » Bug Reports » Bug: Changes to the error reporting level aren't respected by prado « previous next »
Pages: [1] Print
Author Topic: Bug: Changes to the error reporting level aren't respected by prado  (Read 755 times)
acron
Senior Member
***

Karma: 8
Offline Offline

Posts: 76



View Profile
« on: Nov. 01, 2009, 02:06:31 PM »

Prado is not aware of changes to the error reporting level after the framework is loaded.

Assume error_reporting is set to E_ALL and you have a code like in any file (after prado ist started)
Code:
$a = array(0=>'0');
error_reporting(E_ALL & ~E_NOTICE);
echo "a[1]: ".$a[1];

The code above will cause an Notice to be created which shouldn't happen.
I think is caused by the following line:
Code: (PradoBase.php:643)
set_error_handler(array('PradoBase','phpErrorHandler'),error_reporting());

Because the new errorhandler does not care the current reporting level when called (only if it is 0):
Code: (PradoBase.php133)
public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
  {
    if(error_reporting()!=0)
      throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
  }

One possible solution could be modifying phpErrorHandler to take care of the current error reporting level:
Code: (Untested)
public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
  {
    if(error_reporting() & $errno)
      throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
  }

and register phpErrorHandler for all errors:
Code: (Untested)
set_error_handler(array('PradoBase','phpErrorHandler'));


Edit: added register phpErrorHandler for all errors.


Greets acron
« Last Edit: Nov. 01, 2009, 02:24:11 PM by acron » Logged

“A little inaccuracy sometimes saves tons of explanation.” H. H. Munro
rojaro
Administrator
Platinum Member
*****

Karma: 38
Offline Offline

Posts: 684


PRADO aint no voodoo ...


View Profile WWW
« Reply #1 on: Nov. 01, 2009, 08:59:06 PM »

Nice find. Fixed in r2723.
Karma++ Smiley

Greetings from Rostock / Germany
- rojaro -
Logged

A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)
Pages: [1] Print 
« previous next »
Jump to: