Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -29,8 +29,6 @@ class Store implements StoreInterface
private $locks;
/**
* Constructor.
*
* @param string $root The path to the cache directory
*
* @throws \RuntimeException
@@ -62,8 +60,6 @@ class Store implements StoreInterface
/**
* Tries to lock the cache for a given Request, without blocking.
*
* @param Request $request A Request instance
*
* @return bool|string true if the lock is acquired, the path to the current lock otherwise
*/
public function lock(Request $request)
@@ -72,7 +68,7 @@ class Store implements StoreInterface
if (!isset($this->locks[$key])) {
$path = $this->getPath($key);
if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return $path;
}
$h = fopen($path, 'cb');
@@ -91,8 +87,6 @@ class Store implements StoreInterface
/**
* Releases the lock for the given Request.
*
* @param Request $request A Request instance
*
* @return bool False if the lock file does not exist or cannot be unlocked, true otherwise
*/
public function unlock(Request $request)
@@ -133,8 +127,6 @@ class Store implements StoreInterface
/**
* Locates a cached Response for the Request provided.
*
* @param Request $request A Request instance
*
* @return Response|null A Response instance, or null if no cache entry was found
*/
public function lookup(Request $request)
@@ -159,7 +151,7 @@ class Store implements StoreInterface
return;
}
list($req, $headers) = $match;
$headers = $match[1];
if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) {
return $this->restoreResponse($headers, $body);
}
@@ -175,9 +167,6 @@ class Store implements StoreInterface
* Existing entries are read and any that match the response are removed. This
* method calls write with the new list of cache entries.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
*
* @return string The key under which the response is stored
*
* @throws \RuntimeException
@@ -198,7 +187,7 @@ class Store implements StoreInterface
$response->headers->set('X-Content-Digest', $digest);
if (!$response->headers->has('Transfer-Encoding')) {
$response->headers->set('Content-Length', strlen($response->getContent()));
$response->headers->set('Content-Length', \strlen($response->getContent()));
}
}
@@ -210,7 +199,7 @@ class Store implements StoreInterface
$entry[1]['vary'] = array('');
}
if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
$entries[] = $entry;
}
}
@@ -230,8 +219,6 @@ class Store implements StoreInterface
/**
* Returns content digest for $response.
*
* @param Response $response
*
* @return string
*/
protected function generateContentDigest(Response $response)
@@ -242,8 +229,6 @@ class Store implements StoreInterface
/**
* Invalidates all cache entries that match the request.
*
* @param Request $request A Request instance
*
* @throws \RuntimeException
*/
public function invalidate(Request $request)
@@ -314,6 +299,26 @@ class Store implements StoreInterface
return unserialize($entries);
}
/**
* Purges data for the given URL.
*
* This method purges both the HTTP and the HTTPS version of the cache entry.
*
* @param string $url A URL
*
* @return bool true if the URL exists with either HTTP or HTTPS scheme and has been purged, false otherwise
*/
public function purge($url)
{
$http = preg_replace('#^https:#', 'http:', $url);
$https = preg_replace('#^http:#', 'https:', $url);
$purgedHttp = $this->doPurge($http);
$purgedHttps = $this->doPurge($https);
return $purgedHttp || $purgedHttps;
}
/**
* Purges data for the given URL.
*
@@ -321,10 +326,9 @@ class Store implements StoreInterface
*
* @return bool true if the URL exists and has been purged, false otherwise
*/
public function purge($url)
private function doPurge($url)
{
$key = $this->getCacheKey(Request::create($url));
if (isset($this->locks[$key])) {
flock($this->locks[$key], LOCK_UN);
fclose($this->locks[$key]);
@@ -371,28 +375,34 @@ class Store implements StoreInterface
@ftruncate($fp, 0);
@fseek($fp, 0);
$len = @fwrite($fp, $data);
if (strlen($data) !== $len) {
if (\strlen($data) !== $len) {
@ftruncate($fp, 0);
return false;
}
} else {
if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return false;
}
$tmpFile = tempnam(dirname($path), basename($path));
$tmpFile = tempnam(\dirname($path), basename($path));
if (false === $fp = @fopen($tmpFile, 'wb')) {
@unlink($tmpFile);
return false;
}
@fwrite($fp, $data);
@fclose($fp);
if ($data != file_get_contents($tmpFile)) {
@unlink($tmpFile);
return false;
}
if (false === @rename($tmpFile, $path)) {
@unlink($tmpFile);
return false;
}
}
@@ -402,7 +412,7 @@ class Store implements StoreInterface
public function getPath($key)
{
return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6);
return $this->root.\DIRECTORY_SEPARATOR.substr($key, 0, 2).\DIRECTORY_SEPARATOR.substr($key, 2, 2).\DIRECTORY_SEPARATOR.substr($key, 4, 2).\DIRECTORY_SEPARATOR.substr($key, 6);
}
/**
@@ -415,8 +425,6 @@ class Store implements StoreInterface
* headers, use a Vary header to indicate them, and each representation will
* be stored independently under the same cache key.
*
* @param Request $request A Request instance
*
* @return string A key for the given Request
*/
protected function generateCacheKey(Request $request)
@@ -427,8 +435,6 @@ class Store implements StoreInterface
/**
* Returns a cache key for the given Request.
*
* @param Request $request A Request instance
*
* @return string A key for the given Request
*/
private function getCacheKey(Request $request)
@@ -443,8 +449,6 @@ class Store implements StoreInterface
/**
* Persists the Request HTTP headers.
*
* @param Request $request A Request instance
*
* @return array An array of HTTP headers
*/
private function persistRequest(Request $request)
@@ -455,8 +459,6 @@ class Store implements StoreInterface
/**
* Persists the Response HTTP headers.
*
* @param Response $response A Response instance
*
* @return array An array of HTTP headers
*/
private function persistResponse(Response $response)