/** * Populates the cache from current state of the source file. * @param $created \string Unix timestamp when the cache is created (for automatic updates). */ public function create($created = false) { $this->close(); // Close the reader instance just to be sure $messages = $this->group->load($this->code); if (!count($messages) && !$this->group instanceof SingleFileBasedMessageGroup) { if ($this->exists()) { // Delete stale cache files unlink($this->getCacheFileName()); } return; // Don't create empty caches } $hash = md5(file_get_contents($this->group->getSourceFilePath($this->code))); $cache = CdbWriter::open($this->getCacheFileName()); $keys = array_keys($messages); $cache->set('#keys', serialize($keys)); foreach ($messages as $key => $value) { $cache->set($key, $value); } $cache->set('#created', $created ? $created : wfTimestamp()); $cache->set('#updated', wfTimestamp()); $cache->set('#filehash', $hash); $cache->set('#msgcount', count($messages)); ksort($messages); $cache->set('#msghash', md5(serialize($messages))); $cache->set('#version', '3'); $cache->close(); }