Whoops\Exception\ErrorException: fwrite(): write of 7186 bytes failed with errno=28 No space left on device in /var/www/grav/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:131 Stack trace: #0 /var/www/grav/system/src/Grav/Common/Debugger.php(352): Whoops\Run->handleError() #1 [internal function]: Grav\Common\Debugger->deprecatedErrorHandler() #2 /var/www/grav/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(131): fwrite() #3 /var/www/grav/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(117): Monolog\Handler\StreamHandler->streamWrite() #4 /var/www/grav/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(39): Monolog\Handler\StreamHandler->write() #5 /var/www/grav/vendor/monolog/monolog/src/Monolog/Logger.php(344): Monolog\Handler\AbstractProcessingHandler->handle() #6 /var/www/grav/vendor/monolog/monolog/src/Monolog/Logger.php(470): Monolog\Logger->addRecord() #7 /var/www/grav/system/src/Grav/Common/Errors/Errors.php(61): Monolog\Logger->addCritical() #8 /var/www/grav/vendor/filp/whoops/src/Whoops/Handler/CallbackHandler.php(50): Grav\Common\Errors\Errors->Grav\Common\Errors\{closure}() #9 /var/www/grav/vendor/filp/whoops/src/Whoops/Run.php(321): Whoops\Handler\CallbackHandler->handle() #10 [internal function]: Whoops\Run->handleException() #11 {main}
* Writes a string content to file in an atomic way. * * @param string $filename Path to the file where to write the data. * @param string $content The content to write * * @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error. */ protected function writeFile(string $filename, string $content) : bool { $filepath = pathinfo($filename, PATHINFO_DIRNAME); if (! $this->createPathIfNeeded($filepath)) { return false; } if (! is_writable($filepath)) { return false; } $tmpFile = tempnam($filepath, 'swap'); @chmod($tmpFile, 0666 & (~$this->umask)); if (file_put_contents($tmpFile, $content) !== false) { @chmod($tmpFile, 0666 & (~$this->umask)); if (@rename($tmpFile, $filename)) { return true; } @unlink($tmpFile); } return false; } private function getIterator() : Iterator { return new RecursiveIteratorIterator( new RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST );
"tempnam(): file created in the system's temporary directory"
* Writes a string content to file in an atomic way. * * @param string $filename Path to the file where to write the data. * @param string $content The content to write * * @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error. */ protected function writeFile(string $filename, string $content) : bool { $filepath = pathinfo($filename, PATHINFO_DIRNAME); if (! $this->createPathIfNeeded($filepath)) { return false; } if (! is_writable($filepath)) { return false; } $tmpFile = tempnam($filepath, 'swap'); @chmod($tmpFile, 0666 & (~$this->umask)); if (file_put_contents($tmpFile, $content) !== false) { @chmod($tmpFile, 0666 & (~$this->umask)); if (@rename($tmpFile, $filename)) { return true; } @unlink($tmpFile); } return false; } private function getIterator() : Iterator { return new RecursiveIteratorIterator( new RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST );
} fclose($resource); return $lifetime === 0 || $lifetime > time(); } /** * {@inheritdoc} */ protected function doSave($id, $data, $lifeTime = 0) { if ($lifeTime > 0) { $lifeTime = time() + $lifeTime; } $data = serialize($data); $filename = $this->getFilename($id); return $this->writeFile($filename, $lifeTime . PHP_EOL . $data); } }
$namespacedKeysAndValues[$this->getNamespacedId($key)] = $value; } return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime); } /** * {@inheritdoc} */ public function contains($id) { return $this->doContains($this->getNamespacedId($id)); } /** * {@inheritdoc} */ public function save($id, $data, $lifeTime = 0) { return $this->doSave($this->getNamespacedId($id), $data, $lifeTime); } /** * {@inheritdoc} */ public function deleteMultiple(array $keys) { return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys)); } /** * {@inheritdoc} */ public function delete($id) { return $this->doDelete($this->getNamespacedId($id)); } /** * {@inheritdoc}
return $this->driver->fetch($id); } return false; } /** * Stores a new cached entry. * * @param string $id the id of the cached entry * @param array|object $data the data for the cached entry to store * @param int $lifetime the lifetime to store the entry in seconds */ public function save($id, $data, $lifetime = null) { if ($this->enabled) { if ($lifetime === null) { $lifetime = $this->getLifetime(); } $this->driver->save($id, $data, $lifetime); } } /** * Deletes an item in the cache based on the id * * @param string $id the id of the cached data entry * @return bool true if the item was deleted successfully */ public function delete($id) { if ($this->enabled) { return $this->driver->delete($id); } return false; } /** * Deletes all cache
/** * Accessible method to manually reset the pages cache * * @param string $pages_dir */ public function resetPages($pages_dir) { $this->recurse($pages_dir); $this->buildRoutes(); // cache if needed if ($this->grav['config']->get('system.cache.enabled')) { /** @var Cache $cache */ $cache = $this->grav['cache']; /** @var Taxonomy $taxonomy */ $taxonomy = $this->grav['taxonomy']; // save pages, routes, taxonomy, and sort to cache $cache->save($this->pages_cache_id, [$this->instances, $this->routes, $this->children, $taxonomy->taxonomy(), $this->sort]); } } /** * Recursive function to load & build page relationships. * * @param string $directory * @param PageInterface|null $parent * * @return PageInterface * @throws \RuntimeException * @internal */ protected function recurse($directory, PageInterface $parent = null) { $directory = rtrim($directory, DS); $page = new Page; /** @var Config $config */ $config = $this->grav['config'];
break; default: $hash = Folder::lastModifiedFile($pages_dir); } $this->pages_cache_id = md5($pages_dir . $hash . $language->getActive() . $config->checksum()); $cached = $cache->fetch($this->pages_cache_id); if ($cached) { $this->grav['debugger']->addMessage('Page cache hit.'); list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cached; // If pages was found in cache, set the taxonomy $taxonomy->taxonomy($taxonomy_map); } else { $this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..'); // recurse pages and cache result $this->resetPages($pages_dir); } } else { $this->recurse($pages_dir); $this->buildRoutes(); } } /** * Accessible method to manually reset the pages cache * * @param string $pages_dir */ public function resetPages($pages_dir) { $this->recurse($pages_dir); $this->buildRoutes(); // cache if needed if ($this->grav['config']->get('system.cache.enabled')) { /** @var Cache $cache */
public function init() { if ($this->initialized) { return; } $config = $this->grav['config']; $this->ignore_files = $config->get('system.pages.ignore_files'); $this->ignore_folders = $config->get('system.pages.ignore_folders'); $this->ignore_hidden = $config->get('system.pages.ignore_hidden'); $this->instances = []; $this->children = []; $this->routes = []; if (!$this->check_method) { $this->setCheckMethod($config->get('system.cache.check.method', 'file')); } $this->buildPages(); } /** * Get or set last modification time. * * @param int $modified * * @return int|null */ public function lastModified($modified = null) { if ($modified && $modified > $this->last_modified) { $this->last_modified = $modified; } return $this->last_modified; } /** * Returns a list of all pages.
use Grav\Common\Page\Interfaces\PageInterface; use RocketTheme\Toolbox\Event\Event; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class PagesProcessor extends ProcessorBase { public $id = 'pages'; public $title = 'Pages'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { $this->startTimer(); // Dump Cache state $this->container['debugger']->addMessage($this->container['cache']->getCacheStatus()); $this->container['pages']->init(); $this->container->fireEvent('onPagesInitialized', new Event(['pages' => $this->container['pages']])); $this->container->fireEvent('onPageInitialized', new Event(['page' => $this->container['page']])); /** @var PageInterface $page */ $page = $this->container['page']; if (!$page->routable()) { // If no page found, fire event $event = new Event(['page' => $page]); $event->page = null; $event = $this->container->fireEvent('onPageNotFound', $event); if (isset($event->page)) { unset ($this->container['page']); $this->container['page'] = $page = $event->page; } else { throw new \RuntimeException('Page Not Found', 404); } $this->addMessage("Routed to page {$page->rawRoute()} (type: {$page->template()}) [Not Found fallback]");
private $handler; /** @var ContainerInterface|null */ private $container; /** * {@inheritdoc} * @throws InvalidArgumentException */ public function handle(ServerRequestInterface $request): ResponseInterface { $middleware = array_shift($this->middleware); // Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
// Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
*/ namespace Grav\Common\Processors; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class TwigProcessor extends ProcessorBase { public $id = 'twig'; public $title = 'Twig'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { $this->startTimer(); $this->container['twig']->init(); $this->stopTimer(); return $handler->handle($request); } }
private $handler; /** @var ContainerInterface|null */ private $container; /** * {@inheritdoc} * @throws InvalidArgumentException */ public function handle(ServerRequestInterface $request): ResponseInterface { $middleware = array_shift($this->middleware); // Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
// Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
namespace Grav\Common\Processors; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class AssetsProcessor extends ProcessorBase { public $id = '_assets'; public $title = 'Assets'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { $this->startTimer(); $this->container['assets']->init(); $this->container->fireEvent('onAssetsInitialized'); $this->stopTimer(); return $handler->handle($request); } }
private $handler; /** @var ContainerInterface|null */ private $container; /** * {@inheritdoc} * @throws InvalidArgumentException */ public function handle(ServerRequestInterface $request): ResponseInterface { $middleware = array_shift($this->middleware); // Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
// Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
namespace Grav\Common\Processors; use RocketTheme\Toolbox\Event\Event; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class SchedulerProcessor extends ProcessorBase { public $id = '_scheduler'; public $title = 'Scheduler'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { $this->startTimer(); $scheduler = $this->container['scheduler']; $this->container->fireEvent('onSchedulerInitialized', new Event(['scheduler' => $scheduler])); $this->stopTimer(); return $handler->handle($request); } }
private $handler; /** @var ContainerInterface|null */ private $container; /** * {@inheritdoc} * @throws InvalidArgumentException */ public function handle(ServerRequestInterface $request): ResponseInterface { $middleware = array_shift($this->middleware); // Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
// Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }
namespace Grav\Common\Processors; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class BackupsProcessor extends ProcessorBase { public $id = '_backups'; public $title = 'Backups'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { $this->startTimer(); $backups = $this->container['backups']; $backups->init(); $this->stopTimer(); return $handler->handle($request); } }
private $handler; /** @var ContainerInterface|null */ private $container; /** * {@inheritdoc} * @throws InvalidArgumentException */ public function handle(ServerRequestInterface $request): ResponseInterface { $middleware = array_shift($this->middleware); // Use default callable if there is no middleware. if ($middleware === null) { return \call_user_func($this->handler, $request); } if ($middleware instanceof MiddlewareInterface) { return $middleware->process($request, clone $this); } if (null === $this->container || !$this->container->has($middleware)) { throw new InvalidArgumentException( sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class), $middleware ); } array_unshift($this->middleware, $this->container->get($middleware)); return $this->handle($request); } }