mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-12 09:14:26 -05:00
fixing "missing" comments when they were posted during the same second
This commit is contained in:
parent
1d6cfb7f3b
commit
512b3d1172
@ -122,4 +122,24 @@ abstract class zerobin_abstract
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract public function existsComment($pasteid, $parentid, $commentid);
|
abstract public function existsComment($pasteid, $parentid, $commentid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get next free slot for comment from postdate.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $comments
|
||||||
|
* @param int|string $postdate
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function getOpenSlot(&$comments, $postdate)
|
||||||
|
{
|
||||||
|
if (array_key_exists($postdate, $comments))
|
||||||
|
{
|
||||||
|
$parts = explode('.', $postdate, 2);
|
||||||
|
if (!array_key_exists(1, $parts)) $parts[1] = 0;
|
||||||
|
++$parts[1];
|
||||||
|
return $this->addComment($comments, implode('.', $parts));
|
||||||
|
}
|
||||||
|
return $postdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,8 @@ class zerobin_data extends zerobin_abstract
|
|||||||
$comment->meta->parentid = $items[2];
|
$comment->meta->parentid = $items[2];
|
||||||
|
|
||||||
// Store in array
|
// Store in array
|
||||||
$comments[$comment->meta->postdate] = $comment;
|
$key = $this->getOpenSlot($comments, (int) $comment->meta->postdate);
|
||||||
|
$comments[$key] = $comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dir->close();
|
$dir->close();
|
||||||
|
@ -378,7 +378,7 @@ class zerobin_db extends zerobin_abstract
|
|||||||
{
|
{
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
{
|
{
|
||||||
$i = (int) $row['postdate'];
|
$i = $this->getOpenSlot($comments, (int) $row['postdate']);
|
||||||
$comments[$i] = clone $commentTemplate;
|
$comments[$i] = clone $commentTemplate;
|
||||||
$comments[$i]->data = $row['data'];
|
$comments[$i]->data = $row['data'];
|
||||||
$comments[$i]->meta->nickname = $row['nickname'];
|
$comments[$i]->meta->nickname = $row['nickname'];
|
||||||
|
Loading…
Reference in New Issue
Block a user