mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-08-03 12:06:40 -04:00
pass by reference, closes #858
This commit is contained in:
parent
5d4561bd0a
commit
8ad6300c1c
11 changed files with 94 additions and 46 deletions
|
@ -34,7 +34,7 @@ abstract class AbstractData
|
|||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function create($pasteid, array $paste);
|
||||
abstract public function create($pasteid, array &$paste);
|
||||
|
||||
/**
|
||||
* Read a paste.
|
||||
|
@ -72,7 +72,7 @@ abstract class AbstractData
|
|||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function createComment($pasteid, $parentid, $commentid, array $comment);
|
||||
abstract public function createComment($pasteid, $parentid, $commentid, array &$comment);
|
||||
|
||||
/**
|
||||
* Read all comments of paste.
|
||||
|
@ -199,7 +199,7 @@ abstract class AbstractData
|
|||
* @param array $paste
|
||||
* @return array
|
||||
*/
|
||||
protected static function upgradePreV1Format(array $paste)
|
||||
protected static function upgradePreV1Format(array &$paste)
|
||||
{
|
||||
if (array_key_exists('attachment', $paste['meta'])) {
|
||||
$paste['attachment'] = $paste['meta']['attachment'];
|
||||
|
|
|
@ -140,7 +140,7 @@ class Database extends AbstractData
|
|||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
public function create($pasteid, array $paste)
|
||||
public function create($pasteid, array &$paste)
|
||||
{
|
||||
$expire_date = 0;
|
||||
$opendiscussion = $burnafterreading = false;
|
||||
|
@ -297,14 +297,18 @@ class Database extends AbstractData
|
|||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array &$comment)
|
||||
{
|
||||
if (array_key_exists('data', $comment)) {
|
||||
$version = 1;
|
||||
$data = $comment['data'];
|
||||
} else {
|
||||
$version = 2;
|
||||
$data = Json::encode($comment);
|
||||
try {
|
||||
$version = 2;
|
||||
$data = Json::encode($comment);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
list($createdKey, $iconKey) = $this->_getVersionedKeys($version);
|
||||
$meta = $comment['meta'];
|
||||
|
|
|
@ -85,7 +85,7 @@ class Filesystem extends AbstractData
|
|||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
public function create($pasteid, array $paste)
|
||||
public function create($pasteid, array &$paste)
|
||||
{
|
||||
$storagedir = $this->_dataid2path($pasteid);
|
||||
$file = $storagedir . $pasteid . '.php';
|
||||
|
@ -188,7 +188,7 @@ class Filesystem extends AbstractData
|
|||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array &$comment)
|
||||
{
|
||||
$storagedir = $this->_dataid2discussionpath($pasteid);
|
||||
$file = $storagedir . $pasteid . '.' . $commentid . '.' . $parentid . '.php';
|
||||
|
|
|
@ -105,7 +105,7 @@ class GoogleCloudStorage extends AbstractData
|
|||
* @param $payload array to store
|
||||
* @return bool true if successful, otherwise false.
|
||||
*/
|
||||
private function _upload($key, $payload)
|
||||
private function _upload($key, &$payload)
|
||||
{
|
||||
$metadata = array_key_exists('meta', $payload) ? $payload['meta'] : array();
|
||||
unset($metadata['attachment'], $metadata['attachmentname'], $metadata['salt']);
|
||||
|
@ -136,7 +136,7 @@ class GoogleCloudStorage extends AbstractData
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function create($pasteid, array $paste)
|
||||
public function create($pasteid, array &$paste)
|
||||
{
|
||||
if ($this->exists($pasteid)) {
|
||||
return false;
|
||||
|
@ -201,7 +201,7 @@ class GoogleCloudStorage extends AbstractData
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array &$comment)
|
||||
{
|
||||
if ($this->existsComment($pasteid, $parentid, $commentid)) {
|
||||
return false;
|
||||
|
|
|
@ -165,7 +165,7 @@ class S3Storage extends AbstractData
|
|||
* @param $payload array to store
|
||||
* @return bool true if successful, otherwise false.
|
||||
*/
|
||||
private function _upload($key, $payload)
|
||||
private function _upload($key, &$payload)
|
||||
{
|
||||
$metadata = array_key_exists('meta', $payload) ? $payload['meta'] : array();
|
||||
unset($metadata['attachment'], $metadata['attachmentname'], $metadata['salt']);
|
||||
|
@ -191,7 +191,7 @@ class S3Storage extends AbstractData
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function create($pasteid, array $paste)
|
||||
public function create($pasteid, array &$paste)
|
||||
{
|
||||
if ($this->exists($pasteid)) {
|
||||
return false;
|
||||
|
@ -263,7 +263,7 @@ class S3Storage extends AbstractData
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array &$comment)
|
||||
{
|
||||
if ($this->existsComment($pasteid, $parentid, $commentid)) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue