Skip to content

Instantly share code, notes, and snippets.

@sheise
Last active October 11, 2017 18:38
Show Gist options
  • Save sheise/82d576446d9d67a7f2e0a22c345e1114 to your computer and use it in GitHub Desktop.
Save sheise/82d576446d9d67a7f2e0a22c345e1114 to your computer and use it in GitHub Desktop.
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 323a666..68795e3 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1085,7 +1085,25 @@ function drupal_flush_all_caches() {
// sufficient, since new extensions cannot have any primed caches yet.
$module_handler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
- $cache_backend->deleteAll();
+ // Do not delete flysystem data cache.
+ if ($service_id == 'flysystem') {
+ continue;
+ }
+ // Do not delete raw photo data cache.
+ elseif ($service_id == 'default') {
+ $query = \Drupal::database()->select('cache_default', 'c');
+ $query->addField('c', 'cid');
+ $cids = $query->execute()->fetchCol();
+ foreach ($cids as $key => $cid) {
+ if (stripos($cid, 'nt_photo_raw') === 0 || stripos($cid, 'nt_mini_timeline_data') === 0) {
+ unset($cids[$key]);
+ }
+ }
+ $cache_backend->deleteMultiple($cids);
+ }
+ else {
+ $cache_backend->deleteAll();
+ }
}
// Flush asset file caches.
diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 70d74a1..a661afc 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -43,7 +43,25 @@ function drupal_rebuild($class_loader, Request $request) {
$kernel->prepareLegacyRequest($request);
foreach (Cache::getBins() as $bin) {
- $bin->deleteAll();
+ // Do not delete flysytem cache.
+ if ($bin->_serviceId == 'cache.flysystem') {
+ continue;
+ }
+ // Do not delete raw photo data cache.
+ elseif ($bin->_serviceId == 'cache.default') {
+ $query = \Drupal::database()->select('cache_default', 'c');
+ $query->addField('c', 'cid');
+ $cids = $query->execute()->fetchCol();
+ foreach ($cids as $key => $cid) {
+ if (stripos($cid, 'nt_photo_raw') === 0 || stripos($cid, 'nt_mini_timeline_data') === 0) {
+ unset($cids[$key]);
+ }
+ }
+ $bin->deleteMultiple($cids);
+ }
+ else {
+ $bin->deleteAll();
+ }
}
// Disable recording of cached pages.
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index 9e0a374..7a7e667 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -252,7 +252,22 @@ protected function info(Request $request) {
*/
protected function selection(Request $request) {
// Make sure there is no stale theme registry.
- $this->cache->deleteAll();
+ // Do not delete raw photo data cache.
+ if ($this->cache->_serviceId == 'cache.default') {
+ $query = \Drupal::database()->select('cache_default', 'c');
+ $query->addField('c', 'cid');
+ $cids = $query->execute()->fetchCol();
+ foreach ($cids as $key => $cid) {
+ if (stripos($cid, 'nt_photo_raw') === 0 || stripos($cid, 'nt_mini_timeline_data') === 0) {
+ unset($cids[$key]);
+ }
+ }
+ $this->cache->deleteMultiple($cids);
+ }
+ // Do not delete flysytem cache.
+ elseif ($this->cache->_serviceId != 'cache.flysystem') {
+ $this->cache->deleteAll();
+ }
$count = 0;
$incompatible_count = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment