Skip to content

Commit

Permalink
Merge pull request #30144 from owncloud/fix-30112
Browse files Browse the repository at this point in the history
Do not cache app path if app is not found
  • Loading branch information
Vincent Petry authored Jan 16, 2018
2 parents bbe81dd + 5341fdd commit 04c0965
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,24 @@ protected function findAppInDirectories($appId) {
$versionToLoad['url'] .= '/' . $appId;
}
}
$this->appDirs[$appId] = empty($versionToLoad) ? false : $versionToLoad;

if (empty($versionToLoad)) {
return false;
}
$this->saveAppPath($appId, $versionToLoad);
}
return $this->appDirs[$appId];
}

/**
* Save app path and webPath to internal cache
* @param string $appId
* @param string[] $appData
*/
protected function saveAppPath($appId, $appData) {
$this->appDirs[$appId] = $appData;
}

/**
* Get apps roots as an array of path and url
* Wrapper for easy mocking
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/App/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,23 @@ public function appInfoDataProvider() {
[ '2.2.3', '2.2.1', true ]
];
}

public function testPathIsNotCachedForNotFoundApp() {
$appId = 'notexistingapp';

$appManager = $this->getMockBuilder(AppManager::class)
->setMethods(['getAppVersionByPath', 'getAppRoots', 'saveAppPath'])
->disableOriginalConstructor()
->getMock();

$appManager->expects($this->any())
->method('getAppRoots')
->willReturn([]);

$appManager->expects($this->never())
->method('saveAppPath');

$appPath = $appManager->getAppPath($appId);
$this->assertFalse($appPath);
}
}

0 comments on commit 04c0965

Please sign in to comment.