found and resolved issues in database layer, thanks to report in #42
This commit is contained in:
parent
87b41a0c3d
commit
b92b38cee8
@ -340,10 +340,7 @@ class zerobin
|
|||||||
if ($paste->exists())
|
if ($paste->exists())
|
||||||
{
|
{
|
||||||
// The paste itself is the first in the list of encrypted messages.
|
// The paste itself is the first in the list of encrypted messages.
|
||||||
$messages = array_merge(
|
$messages = array_merge(array($paste->get()), $paste->getComments());
|
||||||
array($paste->get()),
|
|
||||||
$paste->getComments()
|
|
||||||
);
|
|
||||||
$this->_data = json_encode($messages);
|
$this->_data = json_encode($messages);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -138,7 +138,7 @@ abstract class zerobin_abstract
|
|||||||
$parts = explode('.', $postdate, 2);
|
$parts = explode('.', $postdate, 2);
|
||||||
if (!array_key_exists(1, $parts)) $parts[1] = 0;
|
if (!array_key_exists(1, $parts)) $parts[1] = 0;
|
||||||
++$parts[1];
|
++$parts[1];
|
||||||
return $this->addComment($comments, implode('.', $parts));
|
return $this->getOpenSlot($comments, implode('.', $parts));
|
||||||
}
|
}
|
||||||
return $postdate;
|
return $postdate;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,11 @@ class zerobin_db extends zerobin_abstract
|
|||||||
array_key_exists('opt', $options)
|
array_key_exists('opt', $options)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// set default options
|
||||||
|
$options['opt'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
|
||||||
|
$options['opt'][PDO::ATTR_EMULATE_PREPARES] = false;
|
||||||
|
$options['opt'][PDO::ATTR_PERSISTENT] = true;
|
||||||
|
|
||||||
// check if the database contains the required tables
|
// check if the database contains the required tables
|
||||||
self::$_type = strtolower(
|
self::$_type = strtolower(
|
||||||
substr($options['dsn'], 0, strpos($options['dsn'], ':'))
|
substr($options['dsn'], 0, strpos($options['dsn'], ':'))
|
||||||
@ -156,12 +161,9 @@ class zerobin_db extends zerobin_abstract
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
self::$_db->exec('SELECT meta FROM ' . self::$_prefix . 'paste LIMIT 1;');
|
self::_exec('SELECT meta FROM ' . self::$_prefix . 'paste LIMIT 1;', array());
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
if ($e->getCode() == 'HY000')
|
self::$_db->exec('ALTER TABLE ' . self::$_prefix . 'paste ADD COLUMN meta TEXT;');
|
||||||
{
|
|
||||||
self::$_db->exec('ALTER TABLE ' . self::$_prefix . 'paste ADD COLUMN meta TEXT;');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,10 +370,6 @@ class zerobin_db extends zerobin_abstract
|
|||||||
array($pasteid)
|
array($pasteid)
|
||||||
);
|
);
|
||||||
|
|
||||||
// create object
|
|
||||||
$commentTemplate = new stdClass;
|
|
||||||
$commentTemplate->meta = new stdClass;
|
|
||||||
|
|
||||||
// create comment list
|
// create comment list
|
||||||
$comments = array();
|
$comments = array();
|
||||||
if (count($rows))
|
if (count($rows))
|
||||||
@ -379,10 +377,13 @@ class zerobin_db extends zerobin_abstract
|
|||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
{
|
{
|
||||||
$i = $this->getOpenSlot($comments, (int) $row['postdate']);
|
$i = $this->getOpenSlot($comments, (int) $row['postdate']);
|
||||||
$comments[$i] = clone $commentTemplate;
|
$comments[$i] = new stdClass;
|
||||||
$comments[$i]->data = $row['data'];
|
$comments[$i]->data = $row['data'];
|
||||||
$comments[$i]->meta->nickname = $row['nickname'];
|
$comments[$i]->meta = new stdClass;
|
||||||
$comments[$i]->meta->vizhash = $row['vizhash'];
|
if (array_key_exists('nickname', $row))
|
||||||
|
$comments[$i]->meta->nickname = $row['nickname'];
|
||||||
|
if (array_key_exists('vizhash', $row))
|
||||||
|
$comments[$i]->meta->vizhash = $row['vizhash'];
|
||||||
$comments[$i]->meta->postdate = $i;
|
$comments[$i]->meta->postdate = $i;
|
||||||
$comments[$i]->meta->commentid = $row['dataid'];
|
$comments[$i]->meta->commentid = $row['dataid'];
|
||||||
$comments[$i]->meta->parentid = $row['parentid'];
|
$comments[$i]->meta->parentid = $row['parentid'];
|
||||||
|
Loading…
Reference in New Issue
Block a user