PEAR is archived and read-only

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

Home » Encryption » Crypt_Blowfish » Bug #4555

Return PEAR_Error instead of dying

Details

Request #4555Return PEAR_Error instead of dying
Submitted2005-06-08 16:59 UTC
Fromjoe at joestump dot net
Assignedmfonda
StatusClosed
PackageCrypt_Blowfish
PHP VersionIrrelevant
OSAll
Roadmaps(Not assigned)

Comments

[2005-06-08 16:59 UTC] joe at joestump dot net

Description:
------------
In all of the major functions you use this code:

PEAR::raiseError('Plain text must be a string', 0,
PEAR_ERROR_DIE);

As a developer I would be expecting the function to either:

a.) return true or false
b.) return a PEAR_Error

Certainly not for the function to kill my whole script if my
encryption attempt failed. For instance, if I have a web
script that takes input from the user, instead of gracefully
handling this error in my own script (ie. "Your string needs
to be plain text!" at the top of my form) the low level
library will fatally kill my script.

IMO, it should simply return a PEAR_Error on failure or true
on success (or void). That way I can do this:

$result = $blowfish->encrypt($notPlainText);
if (PEAR::isError($result)) {
// Fail gracefully
}

The main reason I propose this change: What if it's not
really a fatal error if the encryption doesn't take place?
Especially with setKey() and decrypt().