made all php unit tests pass again
This commit is contained in:
@@ -208,6 +208,13 @@ class Controller
|
||||
|
||||
// Ensure content is not too big.
|
||||
$data = $this->_request->getData();
|
||||
$isComment = array_key_exists('pasteid', $data) &&
|
||||
!empty($data['pasteid']) &&
|
||||
array_key_exists('parentid', $data) &&
|
||||
!empty($data['parentid']);
|
||||
if (!FormatV2::isValid($data, $isComment)) {
|
||||
return $this->_return_message(1, 'Invalid data.');
|
||||
}
|
||||
$sizelimit = $this->_conf->getKey('sizelimit');
|
||||
if (strlen($data['ct']) > $sizelimit) {
|
||||
return $this->_return_message(
|
||||
@@ -220,7 +227,7 @@ class Controller
|
||||
}
|
||||
|
||||
// The user posts a comment.
|
||||
if (!empty($data['pasteid']) && !empty($data['parentid'])) {
|
||||
if ($isComment) {
|
||||
$paste = $this->_model->getPaste($data['pasteid']);
|
||||
if ($paste->exists()) {
|
||||
try {
|
||||
|
||||
@@ -190,11 +190,11 @@ class Filesystem extends AbstractData
|
||||
$comment = DataStore::get($discdir . $filename);
|
||||
$items = explode('.', $filename);
|
||||
// Add some meta information not contained in file.
|
||||
$comment->id = $items[1];
|
||||
$comment->parentid = $items[2];
|
||||
$comment['id'] = $items[1];
|
||||
$comment['parentid'] = $items[2];
|
||||
|
||||
// Store in array
|
||||
$key = $this->getOpenSlot($comments, (int) $comment->meta->postdate);
|
||||
$key = $this->getOpenSlot($comments, (int) $comment['meta']['created']);
|
||||
$comments[$key] = $comment;
|
||||
}
|
||||
}
|
||||
@@ -283,8 +283,8 @@ class Filesystem extends AbstractData
|
||||
if ($this->exists($pasteid)) {
|
||||
$data = $this->read($pasteid);
|
||||
if (
|
||||
property_exists($data->meta, 'expire_date') &&
|
||||
$data->meta->expire_date < time()
|
||||
array_key_exists('expire_date', $data['meta']) &&
|
||||
$data['meta']['expire_date'] < time()
|
||||
) {
|
||||
$pastes[] = $pasteid;
|
||||
if (count($pastes) >= $batchsize) {
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace PrivateBin\Model;
|
||||
use Exception;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\AbstractData;
|
||||
use PrivateBin\FormatV2;
|
||||
|
||||
/**
|
||||
* AbstractModel
|
||||
@@ -104,9 +103,6 @@ abstract class AbstractModel
|
||||
*/
|
||||
public function setData(array $data)
|
||||
{
|
||||
if (!FormatV2::isValid($data, $this instanceof Comment)) {
|
||||
throw new Exception('Invalid data.', 61);
|
||||
}
|
||||
$data = $this->_sanitize($data);
|
||||
$this->_validate($data);
|
||||
$this->_data = $data;
|
||||
|
||||
Reference in New Issue
Block a user