Fixed to be usable outside of a request context.

This commit is contained in:
Loic d'Anterroches 2008-12-05 14:55:11 +01:00
parent 6c5da01319
commit e208a3e1eb
2 changed files with 6 additions and 6 deletions

View File

@ -87,15 +87,15 @@ class IDF_Scm
* Sync the changes in the repository with the timeline. * Sync the changes in the repository with the timeline.
* *
*/ */
public static function syncTimeline($request) public static function syncTimeline($project)
{ {
$cache = Pluf_Cache::factory(); $cache = Pluf_Cache::factory();
$key = 'IDF_Scm:'.$request->project->shortname.':lastsync'; $key = 'IDF_Scm:'.$project->shortname.':lastsync';
if (null === ($res=$cache->get($key))) { if (null === ($res=$cache->get($key))) {
$scm = IDF_Scm::get($request->project); $scm = IDF_Scm::get($project);
foreach ($scm->getBranches() as $branche) { foreach ($scm->getBranches() as $branche) {
foreach ($scm->getChangeLog($branche, 25) as $change) { foreach ($scm->getChangeLog($branche, 25) as $change) {
IDF_Commit::getOrAdd($change, $request->project); IDF_Commit::getOrAdd($change, $project);
} }
} }
$cache->set($key, true, (int)(Pluf::f('cache_timeout', 300)/2)); $cache->set($key, true, (int)(Pluf::f('cache_timeout', 300)/2));

View File

@ -79,7 +79,7 @@ class IDF_Views_Project
$rights = array(); $rights = array();
if (true === IDF_Precondition::accessSource($request)) { if (true === IDF_Precondition::accessSource($request)) {
$rights[] = '\'IDF_Commit\''; $rights[] = '\'IDF_Commit\'';
IDF_Scm::syncTimeline($request); IDF_Scm::syncTimeline($request->project);
} }
if (true === IDF_Precondition::accessIssues($request)) { if (true === IDF_Precondition::accessIssues($request)) {
$rights[] = '\'IDF_Issue\''; $rights[] = '\'IDF_Issue\'';
@ -156,7 +156,7 @@ class IDF_Views_Project
$rights = array(); $rights = array();
if (true === IDF_Precondition::accessSource($request)) { if (true === IDF_Precondition::accessSource($request)) {
$rights[] = '\'IDF_Commit\''; $rights[] = '\'IDF_Commit\'';
IDF_Scm::syncTimeline($request); IDF_Scm::syncTimeline($request->project);
} }
if (true === IDF_Precondition::accessIssues($request)) { if (true === IDF_Precondition::accessIssues($request)) {
$rights[] = '\'IDF_Issue\''; $rights[] = '\'IDF_Issue\'';