mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Fixes to allow not just ‘default/file’ cache in CLI (#1294)
* Fixes to allow not just ‘default/file’ cache in CLI * vendor updates * Better solution * Added cli_compatibility to system blueprint * Fall back to ‘file’ if cli_compatibility and (auto or volatile)
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.1.16
|
||||
## xx/xx/2017
|
||||
|
||||
1. [](#improved)
|
||||
* Allowed CLI to use non-volatile cache drivers for better integration with CLI and Web caches
|
||||
|
||||
# v1.1.15
|
||||
## 01/30/2017
|
||||
|
||||
|
||||
88
composer.lock
generated
88
composer.lock
generated
@@ -899,16 +899,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v2.8.16",
|
||||
"version": "v2.8.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "2e18b8903d9c498ba02e1dfa73f64d4894bb6912"
|
||||
"reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/2e18b8903d9c498ba02e1dfa73f64d4894bb6912",
|
||||
"reference": "2e18b8903d9c498ba02e1dfa73f64d4894bb6912",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4",
|
||||
"reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -956,7 +956,7 @@
|
||||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-08T20:43:03+00:00"
|
||||
"time": "2017-02-06T12:04:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
@@ -1017,7 +1017,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.8.16",
|
||||
"version": "v2.8.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
@@ -1195,16 +1195,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v2.8.16",
|
||||
"version": "v2.8.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "8d2df79c132df0b14df305727fb2c26d33ab5492"
|
||||
"reference": "eb4526a20ba9e691f50a7510ea3db3728ada958f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/8d2df79c132df0b14df305727fb2c26d33ab5492",
|
||||
"reference": "8d2df79c132df0b14df305727fb2c26d33ab5492",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/eb4526a20ba9e691f50a7510ea3db3728ada958f",
|
||||
"reference": "eb4526a20ba9e691f50a7510ea3db3728ada958f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1254,20 +1254,20 @@
|
||||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"time": "2017-01-02T20:30:24+00:00"
|
||||
"time": "2017-01-24T13:02:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.8.16",
|
||||
"version": "v2.8.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2"
|
||||
"reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2",
|
||||
"reference": "dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153",
|
||||
"reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1303,7 +1303,7 @@
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-03T13:49:52+00:00"
|
||||
"time": "2017-01-21T16:40:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
@@ -1429,16 +1429,16 @@
|
||||
},
|
||||
{
|
||||
"name": "codeception/codeception",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Codeception/Codeception.git",
|
||||
"reference": "0a87d4b19070a24636125993450a9d3f698a6663"
|
||||
"reference": "0204f1362040d3e408404af2545e5fa27e8964e2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/0a87d4b19070a24636125993450a9d3f698a6663",
|
||||
"reference": "0a87d4b19070a24636125993450a9d3f698a6663",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/0204f1362040d3e408404af2545e5fa27e8964e2",
|
||||
"reference": "0204f1362040d3e408404af2545e5fa27e8964e2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1449,7 +1449,7 @@
|
||||
"guzzlehttp/guzzle": ">=4.1.4 <7.0",
|
||||
"guzzlehttp/psr7": "~1.0",
|
||||
"php": ">=5.4.0 <8.0",
|
||||
"phpunit/php-code-coverage": ">=2.1.3 <5.0",
|
||||
"phpunit/php-code-coverage": ">=2.2.4 <5.0",
|
||||
"phpunit/phpunit": ">4.8.20 <6.0",
|
||||
"sebastian/comparator": "~1.1",
|
||||
"sebastian/diff": "^1.4",
|
||||
@@ -1517,7 +1517,7 @@
|
||||
"functional testing",
|
||||
"unit testing"
|
||||
],
|
||||
"time": "2017-01-20T00:54:15+00:00"
|
||||
"time": "2017-02-04T02:04:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
@@ -2295,16 +2295,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.8.34",
|
||||
"version": "4.8.35",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "7eb45205d27edd94bd2b3614085ea158bd1e2bca"
|
||||
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7eb45205d27edd94bd2b3614085ea158bd1e2bca",
|
||||
"reference": "7eb45205d27edd94bd2b3614085ea158bd1e2bca",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87",
|
||||
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2363,7 +2363,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-01-26T16:15:36+00:00"
|
||||
"time": "2017-02-06T05:18:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
@@ -2845,16 +2845,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/browser-kit",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/browser-kit.git",
|
||||
"reference": "548f8230bad9f77463b20b15993a008f03e96db5"
|
||||
"reference": "394a2475a3a89089353fde5714a7f402fbb83880"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/548f8230bad9f77463b20b15993a008f03e96db5",
|
||||
"reference": "548f8230bad9f77463b20b15993a008f03e96db5",
|
||||
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/394a2475a3a89089353fde5714a7f402fbb83880",
|
||||
"reference": "394a2475a3a89089353fde5714a7f402fbb83880",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2898,11 +2898,11 @@
|
||||
],
|
||||
"description": "Symfony BrowserKit Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-01-31T21:49:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/css-selector.git",
|
||||
@@ -2955,16 +2955,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/dom-crawler",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dom-crawler.git",
|
||||
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024"
|
||||
"reference": "b814b41373fc4e535aff8c765abe39545216f391"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
|
||||
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
|
||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b814b41373fc4e535aff8c765abe39545216f391",
|
||||
"reference": "b814b41373fc4e535aff8c765abe39545216f391",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3007,11 +3007,11 @@
|
||||
],
|
||||
"description": "Symfony DomCrawler Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-01-21T17:14:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
@@ -3060,16 +3060,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v3.2.2",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893"
|
||||
"reference": "32646a7cf53f3956c76dcb5c82555224ae321858"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/32646a7cf53f3956c76dcb5c82555224ae321858",
|
||||
"reference": "32646a7cf53f3956c76dcb5c82555224ae321858",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3105,7 +3105,7 @@
|
||||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-01-02T20:32:22+00:00"
|
||||
"time": "2017-02-03T12:11:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
|
||||
@@ -499,6 +499,55 @@ form:
|
||||
wincache: WinCache
|
||||
redis: Redis
|
||||
|
||||
cache.prefix:
|
||||
type: text
|
||||
size: x-small
|
||||
label: PLUGIN_ADMIN.CACHE_PREFIX
|
||||
help: PLUGIN_ADMIN.CACHE_PREFIX_HELP
|
||||
placeholder: PLUGIN_ADMIN.CACHE_PREFIX_PLACEHOLDER
|
||||
|
||||
cache.cli_compatibility:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.CLI_COMPATIBILITY
|
||||
help: PLUGIN_ADMIN.CLI_COMPATIBILITY_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
cache.lifetime:
|
||||
type: text
|
||||
size: small
|
||||
append: NICETIME.SECOND_PLURAL
|
||||
label: PLUGIN_ADMIN.LIFETIME
|
||||
help: PLUGIN_ADMIN.LIFETIME_HELP
|
||||
validate:
|
||||
type: number
|
||||
|
||||
cache.gzip:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.GZIP_COMPRESSION
|
||||
help: PLUGIN_ADMIN.GZIP_COMPRESSION_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
cache.allow_webserver_gzip:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.ALLOW_WEBSERVER_GZIP
|
||||
help: PLUGIN_ADMIN.ALLOW_WEBSERVER_GZIP_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
cache.memcache.server:
|
||||
type: text
|
||||
size: medium
|
||||
@@ -548,43 +597,6 @@ form:
|
||||
help: PLUGIN_ADMIN.REDIS_PORT_HELP
|
||||
placeholder: "6379"
|
||||
|
||||
cache.prefix:
|
||||
type: text
|
||||
size: x-small
|
||||
label: PLUGIN_ADMIN.CACHE_PREFIX
|
||||
help: PLUGIN_ADMIN.CACHE_PREFIX_HELP
|
||||
placeholder: PLUGIN_ADMIN.CACHE_PREFIX_PLACEHOLDER
|
||||
|
||||
cache.lifetime:
|
||||
type: text
|
||||
size: small
|
||||
append: NICETIME.SECOND_PLURAL
|
||||
label: PLUGIN_ADMIN.LIFETIME
|
||||
help: PLUGIN_ADMIN.LIFETIME_HELP
|
||||
validate:
|
||||
type: number
|
||||
|
||||
cache.gzip:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.GZIP_COMPRESSION
|
||||
help: PLUGIN_ADMIN.GZIP_COMPRESSION_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
cache.allow_webserver_gzip:
|
||||
type: toggle
|
||||
label: PLUGIN_ADMIN.ALLOW_WEBSERVER_GZIP
|
||||
help: PLUGIN_ADMIN.ALLOW_WEBSERVER_GZIP_HELP
|
||||
highlight: 0
|
||||
options:
|
||||
1: PLUGIN_ADMIN.YES
|
||||
0: PLUGIN_ADMIN.NO
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
twig:
|
||||
type: section
|
||||
@@ -1114,6 +1126,6 @@ form:
|
||||
custom_base_url:
|
||||
type: text
|
||||
size: medium
|
||||
placeholder: "e.g. http://localhost:8080"
|
||||
placeholder: "e.g. http://yoursite.com/yourpath"
|
||||
label: PLUGIN_ADMIN.CUSTOM_BASE_URL
|
||||
help: PLUGIN_ADMIN.CUSTOM_BASE_URL_HELP
|
||||
|
||||
@@ -5,7 +5,7 @@ param_sep: ':' # Parameter separator, use ';' for A
|
||||
wrapped_site: false # For themes/plugins to know if Grav is wrapped by another platform
|
||||
reverse_proxy_setup: false # Running in a reverse proxy scenario with different webserver ports than proxy
|
||||
force_ssl: false # If enabled, Grav forces to be accessed via HTTPS (NOTE: Not an ideal solution)
|
||||
custom_base_url: '' # Set the base_url manually
|
||||
custom_base_url: '' # Set the base_url manually, e.g. http://yoursite.com/yourpath
|
||||
|
||||
languages:
|
||||
supported: [] # List of languages supported. eg: [en, fr, de]
|
||||
@@ -71,6 +71,7 @@ cache:
|
||||
method: file # Method to check for updates in pages: file|folder|hash|none
|
||||
driver: auto # One of: auto|file|apc|xcache|memcache|wincache
|
||||
prefix: 'g' # Cache prefix string (prevents cache conflicts)
|
||||
cli_compatibility: false # Ensures only non-volatile drivers are used (file, redis, memcache, etc.)
|
||||
lifetime: 604800 # Lifetime of cached data in seconds (0 = infinite)
|
||||
gzip: false # GZip compress the page output
|
||||
allow_webserver_gzip: false # If true, `content-encoding: identity` but connection isn't closed before `onShutDown()` event
|
||||
|
||||
@@ -173,6 +173,12 @@ class Cache extends Getters
|
||||
$setting = $this->driver_setting;
|
||||
$driver_name = 'file';
|
||||
|
||||
// CLI compatibility requires a non-volatile cache driver
|
||||
if ($this->config->get('system.cache.cli_compatibility') && (
|
||||
$setting == 'auto' || $this->isVolatileDriver($setting))) {
|
||||
$setting = $driver_name;
|
||||
}
|
||||
|
||||
if (!$setting || $setting == 'auto') {
|
||||
if (extension_loaded('apcu')) {
|
||||
$driver_name = 'apcu';
|
||||
@@ -437,4 +443,39 @@ class Cache extends Getters
|
||||
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current driver name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDriverName()
|
||||
{
|
||||
return $this->driver_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current driver setting
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDriverSetting()
|
||||
{
|
||||
return $this->driver_setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* is this driver a volatile driver in that it resides in PHP process memory
|
||||
*
|
||||
* @param $setting
|
||||
* @return bool
|
||||
*/
|
||||
public function isVolatileDriver($setting)
|
||||
{
|
||||
if (in_array($setting, ['apc', 'apcu', 'xcache', 'wincache'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,13 @@ class Uri
|
||||
}
|
||||
|
||||
// Set some defaults
|
||||
$this->root = $grav['config']->get('system.custom_base_url') ?: $this->base . $this->root_path;
|
||||
if ($grav['config']->get('system.custom_base_url')) {
|
||||
$this->root_path = parse_url($grav['config']->get('system.custom_base_url'), PHP_URL_PATH);
|
||||
$this->root = $grav['config']->get('system.custom_base_url');
|
||||
} else {
|
||||
$this->root = $this->base . $this->root_path;
|
||||
}
|
||||
|
||||
$this->url = $this->base . $this->uri;
|
||||
|
||||
// get any params and remove them
|
||||
|
||||
@@ -41,12 +41,11 @@ trait ConsoleTrait
|
||||
*/
|
||||
public function setupConsole(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (Grav::instance()) {
|
||||
Grav::instance()['config']->set('system.cache.driver', 'default');
|
||||
}
|
||||
// Initialize cache with CLI compatibility
|
||||
Grav::instance()['config']->set('system.cache.cli_compatibility', true);
|
||||
Grav::instance()['cache'];
|
||||
|
||||
$this->argv = $_SERVER['argv'][0];
|
||||
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user