Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773229
D356.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 5:34 AM
Size
3 KB
Mime Type
text/x-diff
Expires
Mon, Feb 3, 5:34 AM (13 h, 33 m)
Engine
blob
Format
Raw Data
Handle
556481
Attached To
D356: INP-1760 Don't attempt to change "CachedUrls" table for units, that are not used in Mod-Rewrite URLs
D356.id.diff
View Options
Index: branches/5.2.x/core/kernel/managers/cache_manager.php
===================================================================
--- branches/5.2.x/core/kernel/managers/cache_manager.php
+++ branches/5.2.x/core/kernel/managers/cache_manager.php
@@ -800,12 +800,29 @@
$this->setCache($serial_name, (int)$this->getCache($serial_name) + 1);
if (!defined('IS_INSTALL') || !IS_INSTALL) {
- // delete cached mod-rewrite urls related to given prefix and id
- $delete_clause = isset($id) ? $prefix . ':' . $id : $prefix;
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $prefixes = $this->Application->getCache('cached_urls_unit_prefixes');
+ }
+ else {
+ $prefixes = $this->Application->getDBCache('cached_urls_unit_prefixes');
- $sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls
- WHERE Prefixes LIKE ' . $this->Conn->qstr('%|' . $delete_clause . '|%');
- $this->Conn->Query($sql);
+ if ( $prefixes !== false ) {
+ $prefixes = unserialize($prefixes);
+ }
+ }
+
+ if ( !$prefixes ) {
+ $prefixes = array('c', 'lang', 'theme');
+ }
+
+ if ( in_array($prefix, $prefixes) ) {
+ // delete cached mod-rewrite urls related to given prefix and id
+ $delete_clause = isset($id) ? $prefix . ':' . $id : $prefix;
+
+ $sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls
+ WHERE Prefixes LIKE ' . $this->Conn->qstr('%|' . $delete_clause . '|%');
+ $this->Conn->Query($sql);
+ }
}
}
Index: branches/5.2.x/core/units/admin/admin_config.php
===================================================================
--- branches/5.2.x/core/units/admin/admin_config.php
+++ branches/5.2.x/core/units/admin/admin_config.php
@@ -31,6 +31,7 @@
'ScheduledTasks' => Array (
'optimize_performance' => Array ('EventName' => 'OnOptimizePerformance', 'RunSchedule' => '0 0 * * *'),
'purge_expired_database_cache' => Array ('EventName' => 'OnPurgeExpiredDatabaseCacheScheduledTask', 'RunSchedule' => '0 0,12 * * *'),
+ 'populate_url_unit_cache' => array('EventName' => 'OnPopulateUrlUnitCacheScheduledTask', 'RunSchedule' => '0 * * * *'),
),
'TitlePresets' => Array (
Index: branches/5.2.x/core/units/admin/admin_events_handler.php
===================================================================
--- branches/5.2.x/core/units/admin/admin_events_handler.php
+++ branches/5.2.x/core/units/admin/admin_events_handler.php
@@ -1234,6 +1234,37 @@
$this->Conn->Query($sql);
}
+ /**
+ * Populates URL unit cache
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnPopulateUrlUnitCacheScheduledTask(kEvent $event)
+ {
+ $sql = 'SELECT DISTINCT Prefixes
+ FROM ' . TABLE_PREFIX . 'CachedUrls';
+ $urls = $this->Conn->GetColIterator($sql);
+ $prefixes = array();
+
+ foreach ( $urls as $url_prefixes ) {
+ $url_prefixes = explode('|', trim($url_prefixes, '|'));
+
+ foreach ( $url_prefixes as $url_prefix ) {
+ $url_prefix = explode(':', $url_prefix);
+ $prefixes[$url_prefix[0]] = 1;
+ }
+ }
+
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->setCache('cached_urls_unit_prefixes', array_keys($prefixes), 3600);
+ }
+ else {
+ $this->Application->setDBCache('cached_urls_unit_prefixes', serialize(array_keys($prefixes)), 3600);
+ }
+ }
+
}
Event Timeline
Log In to Comment