Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Error in slug generation, make sure to look at the reserved slugs whe…
Browse files Browse the repository at this point in the history
…n building new ones
  • Loading branch information
cdujeu committed Feb 18, 2015
1 parent d30ce58 commit e861e31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/core/classes/class.ConfService.php
Expand Up @@ -766,6 +766,23 @@ public static function findRepositoryByIdOrAlias($idOrAlias)
return null;
}

/**
* Get the reserved slugs used for config defined repositories
* @return array
*/
public static function reservedSlugsFromConfig(){
$inst = self::getInstance();
$slugs = array();
if(isSet($inst->configs["DEFAULT_REPOSITORIES"])){
foreach($inst->configs["DEFAULT_REPOSITORIES"] as $repo){
if(isSet($repo["AJXP_SLUG"])){
$slugs[] = $repo["AJXP_SLUG"];
}
}
}
return $slugs;
}

/**
* Retrieve a repository object
*
Expand Down
4 changes: 4 additions & 0 deletions core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -367,6 +367,10 @@ protected function uniquifySlug($slug, $repositoryId = null){
$res = dibi::query("SELECT [slug],[uuid] FROM [ajxp_repo] WHERE [slug] LIKE '".$slug."%'");
}
$existingSlugs = $res->fetchPairs();
$configSlugs = ConfService::reservedSlugsFromConfig();
if(in_array($slug, $configSlugs)){
$existingSlugs[$slug] = $slug;
}
if(!count($existingSlugs)) return $slug;
$index = 1;
$base = $slug;
Expand Down

0 comments on commit e861e31

Please sign in to comment.