From: Marcel Werk Date: Thu, 22 Sep 2011 20:30:01 +0000 (+0200) Subject: Language object cache added X-Git-Tag: 2.0.0_Beta_1~1776 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=13509d87f2f06f67c0314d0cc6e06176bbdfd8d6;p=GitHub%2FWoltLab%2FWCF.git Language object cache added --- diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php index 13864d7b9e..e452a83696 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -1,6 +1,7 @@ prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - // language data - $data['languages'][$row['languageID']] = $row; - - // language to packages - if (!isset($languageToPackages[$row['languageID']])) { - $languageToPackages[$row['languageID']] = array(); - } - $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']]; - + $languageList = new LanguageList(); + $languageList->sqlLimit = 0; + $languageList->readObjects(); + $data['languages'] = $languageList->getObjects(); + foreach ($languageList->getObjects() as $language) { // default language - if ($row['isDefault']) { - $data['default'] = $row['languageID']; + if ($language->isDefault) { + $data['default'] = $language->languageID; } // language code to language id - $data['codes'][$row['languageCode']] = $row['languageID']; + $data['codes'][$language->languageCode] = $language->languageID; } // get language categories diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index 2ed6c297fa..7b4ea48460 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -52,12 +52,11 @@ class LanguageFactory extends SingletonFactory { */ public function getLanguage($languageID) { if (!isset($this->languages[$languageID])) { - $language = new Language($languageID); - if (!$language->languageID) { + if (!isset($this->cache['languages'][$languageID])) { return null; } - $this->languages[$language->languageID] = $language; + $this->languages[$languageID] = $this->cache['languages'][$languageID]; } return $this->languages[$languageID]; @@ -147,14 +146,14 @@ class LanguageFactory extends SingletonFactory { } // get default language - $defaultLanguageCode = $this->cache['languages'][$this->cache['default']]['languageCode']; + $defaultLanguageCode = $this->cache['languages'][$this->cache['default']]->languageCode; // get preferred language $languageCode = self::getPreferredLanguage($availableLanguageCodes, $defaultLanguageCode); // get language id of preferred language foreach ($this->cache['languages'] as $key => $language) { - if ($language['languageCode'] == $languageCode) { + if ($language->languageCode == $languageCode) { return $key; } } @@ -268,7 +267,7 @@ class LanguageFactory extends SingletonFactory { $availableLanguages = array(); if (isset($this->cache['packages'][$packageID])) { foreach ($this->cache['packages'][$packageID] as $availableLanguageID) { - if ($this->cache['languages'][$availableLanguageID]['hasContent']) { + if ($this->cache['languages'][$availableLanguageID]->hasContent) { $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID); } }