fixing nasty deletion bug from #15, included unit tests to trigger it
and reworked persistence classes to through exceptions rather to fail silently
This commit is contained in:
@@ -38,8 +38,8 @@ class zerobin_data extends zerobin_abstract
|
||||
{
|
||||
// if given update the data directory
|
||||
if (
|
||||
is_array($options) &&
|
||||
array_key_exists('dir', $options)
|
||||
is_array($options) &&
|
||||
array_key_exists('dir', $options)
|
||||
) self::$_dir = $options['dir'] . DIRECTORY_SEPARATOR;
|
||||
// if needed initialize the singleton
|
||||
if(!(self::$_instance instanceof zerobin_data)) {
|
||||
|
||||
@@ -80,13 +80,6 @@ class zerobin_db extends zerobin_abstract
|
||||
array_key_exists('opt', $options)
|
||||
)
|
||||
{
|
||||
self::$_db = new PDO(
|
||||
$options['dsn'],
|
||||
$options['usr'],
|
||||
$options['pwd'],
|
||||
$options['opt']
|
||||
);
|
||||
|
||||
// check if the database contains the required tables
|
||||
self::$_type = strtolower(
|
||||
substr($options['dsn'], 0, strpos($options['dsn'], ':'))
|
||||
@@ -132,9 +125,16 @@ class zerobin_db extends zerobin_abstract
|
||||
throw new Exception(
|
||||
'PDO type ' .
|
||||
self::$_type .
|
||||
' is currently not supported.'
|
||||
' is currently not supported.',
|
||||
5
|
||||
);
|
||||
}
|
||||
self::$_db = new PDO(
|
||||
$options['dsn'],
|
||||
$options['usr'],
|
||||
$options['pwd'],
|
||||
$options['opt']
|
||||
);
|
||||
$statement = self::$_db->query($sql);
|
||||
$tables = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||
|
||||
@@ -266,7 +266,7 @@ class zerobin_db extends zerobin_abstract
|
||||
array($pasteid)
|
||||
);
|
||||
if (
|
||||
array_key_exists($pasteid, self::$_cache)
|
||||
array_key_exists($pasteid, self::$_cache)
|
||||
) unset(self::$_cache[$pasteid]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user