Why am I getting the "Disable Exception" error?

I have the following PHP code:

foreach (...) {
  try {
    $Object = MyDataMapper::getById(123);

    if (!$Object->propertyIsTrue()) {
      continue;
    }
  }
  catch (Exception $e) {
    continue;
  }
}

      

MyDataMapper :: getById () throws an exception if no database record is found. Here is the definition of this method:

public static function getById($id) {
  $query = "SELECT * FROM table WHERE id = $id";

  $Connection = Database::getInstance();
  $Statement = $Connection->prepare($query);
  $Statement->execute();

  if ($Statement->rowCount() == 0) {
    throw new Exception("Record does not exist!");
    return null;
  }

  $row = $Statement->fetch();

  return self::create($row);
}

      

When this code is called for a database record id that does not exist, I get a fatal thrown "Exception" exception.

Why is this? Clearly I caught the exception ... What am I doing wrong?

I'm pretty sure an exception is being thrown. Is there something wrong with the way I am handling the exception - possibly with a continuation?

EDIT

Thanks to help from jitter, the solution to this problem solves this problem:

if (!$Object->propertyIsTrue()) {
 // Workaround to eAccelerator bug 291 (http://eaccelerator.net/ticket/291).
 $foo = 555;
 continue;
}

      

+2


source to share


2 answers


What PHP version? → 5.2.9

Are you using eAccelerator (which version)? → 0.9.5.3 with ionCube PHP Loader v3.1.34

What kind of exception are you throwing? → normal exception


There are known issues in some versions of PHP + eAccelerator regarding try-catch block optimization.

Check bug-tracker eAccelerator:



For starter check tickets

291 Incorrect Exception Handling

314 No Exceptions Found

317 Exception not found

and try disabling eAccelerator.

+2


source


I think it might be because you are calling a static method, but I could be wrong. Is it possible for you to test this by instantiating MyDataMapper and calling the method from the object itself?



0


source







All Articles