diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-02 13:41:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 13:41:53 +0200 |
commit | 93624c30286fa34279678efe053da77505b587cd (patch) | |
tree | 38bdf32908d52e42e6313c773a644ea0a8b45cb0 | |
parent | ab876619dc6697851fee54dbee24609318e0c0fb (diff) | |
parent | 7f84f05e4dc5384f649196520a6ed77bab60d995 (diff) | |
download | nextcloud-server-93624c30286fa34279678efe053da77505b587cd.tar.gz nextcloud-server-93624c30286fa34279678efe053da77505b587cd.zip |
Merge pull request #1239 from nextcloud/cache_info_parsing
Cache parsing of info.xml
-rw-r--r-- | lib/private/AppFramework/App.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index 5a8099ec7d0..427a850f396 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -42,6 +42,8 @@ use OCP\AppFramework\Http\ICallbackResponse; */ class App { + /** @var string[] */ + private static $nameSpaceCache = []; /** * Turns an app id into a namespace by either reading the appinfo.xml's @@ -52,6 +54,11 @@ class App { * @return string the starting namespace for the app */ public static function buildAppNamespace($appId, $topNamespace='OCA\\') { + // Hit the cache! + if (isset(self::$nameSpaceCache[$appId])) { + return $topNamespace . self::$nameSpaceCache[$appId]; + } + // first try to parse the app's appinfo/info.xml <namespace> tag $appPath = OC_App::getAppPath($appId); if ($appPath !== false) { @@ -63,14 +70,16 @@ class App { if ($xml) { $result = $xml->xpath('/info/namespace'); if ($result && count($result) > 0) { + self::$nameSpaceCache[$appId] = trim((string) $result[0]); // take first namespace result - return $topNamespace . trim((string) $result[0]); + return $topNamespace . self::$nameSpaceCache[$appId]; } } } } // if the tag is not found, fall back to uppercasing the first letter - return $topNamespace . ucfirst($appId); + self::$nameSpaceCache[$appId] = ucfirst($appId); + return $topNamespace . self::$nameSpaceCache[$appId]; } |