Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Replaced opis/closure with laravel/serializable-closure #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"illuminate/cache": "^5.5|~6|~7|~8|~9|~10",
"illuminate/filesystem": "^5.5|~6|~7|~8|~9|~10",
"nesbot/carbon": "^2.39",
"opis/closure": "^3.5"
"laravel/serializable-closure": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
Expand Down
3 changes: 3 additions & 0 deletions src/Intervention/Image/CachedImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class CachedImage extends Image
{

public $cachekey;

public function setFromOriginal(Image $original, $cachekey)
{
$this->driver = $original->driver;
Expand Down
14 changes: 7 additions & 7 deletions src/Intervention/Image/HashableClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Intervention\Image;

use Closure;
use Opis\Closure\SerializableClosure;
use Laravel\SerializableClosure\UnsignedSerializableClosure;

class HashableClosure
{
/**
* Original closure
*
* @var \Opis\Closure\SerializableClosure
* @var \Laravel\SerializableClosure\UnsignedSerializableClosure
*/
protected $closure;

Expand All @@ -31,8 +31,7 @@ public function __construct(Closure $closure)
*/
public function setClosure(Closure $closure)
{
$closure = new SerializableClosure($closure);
$closure->removeSecurityProvider();
$closure = new UnsignedSerializableClosure($closure);

$this->closure = $closure;

Expand All @@ -42,7 +41,7 @@ public function setClosure(Closure $closure)
/**
* Get current closure
*
* @return \Opis\Closure\SerializableClosure
* @return \Laravel\SerializableClosure\UnsignedSerializableClosure
*/
public function getClosure()
{
Expand All @@ -52,7 +51,7 @@ public function getClosure()
/**
* Get hash of current closure
*
* This method uses "opis/closure" to serialize the closure. "opis/closure",
* This method uses "laravel/serializable-closure" to serialize the closure. "laravel/serializable-closure",
* however, adds a identifier by "spl_object_hash" to each serialize
* call, making it impossible to create unique hashes. This method
* removes this identifier and builds the hash afterwards.
Expand All @@ -61,7 +60,8 @@ public function getClosure()
*/
public function getHash()
{
$data = unserialize($this->closure->serialize());
$serializable = $this->closure->__serialize();
$data = $serializable['serializable']->__serialize();

unset($data['self']); // unset identifier added by spl_object_hash

Expand Down
4 changes: 2 additions & 2 deletions tests/HashableClosureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Intervention\Image\Test;

use Intervention\Image\HashableClosure;
use Opis\Closure\SerializableClosure;
use Laravel\SerializableClosure\UnsignedSerializableClosure;
use PHPUnit\Framework\TestCase;

class HashableClosureTest extends TestCase
Expand All @@ -28,7 +28,7 @@ public function testSetGetClosure()
});

$this->assertInstanceOf(HashableClosure::class, $result);
$this->assertInstanceOf(SerializableClosure::class, $hashable->getClosure());
$this->assertInstanceOf(UnsignedSerializableClosure::class, $hashable->getClosure());
}

public function testGetHash()
Expand Down