Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / PageCache / RequestPolicy / CommandLineOrUnsafeMethod.php
1 <?php
2
3 namespace Drupal\Core\PageCache\RequestPolicy;
4
5 use Drupal\Core\PageCache\RequestPolicyInterface;
6 use Symfony\Component\HttpFoundation\Request;
7
8 /**
9  * Reject when running from the command line or when HTTP method is not safe.
10  *
11  * The policy denies caching if the request was initiated from the command line
12  * interface (drush) or the request method is neither GET nor HEAD (see RFC
13  * 2616, section 9.1.1 - Safe Methods).
14  */
15 class CommandLineOrUnsafeMethod implements RequestPolicyInterface {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function check(Request $request) {
21     if ($this->isCli() || !$request->isMethodCacheable()) {
22       return static::DENY;
23     }
24   }
25
26   /**
27    * Indicates whether this is a CLI request.
28    */
29   protected function isCli() {
30     return PHP_SAPI === 'cli';
31   }
32
33 }