@@ -324,12 +324,15 @@ public function addOption($oName, $oValue)
324
324
*/
325
325
public function getOption ($ oName , $ safe =false , $ resolveUser = null )
326
326
{
327
- if (!$ safe && $ this ->inferOptionsFromParent ) {
328
- if (!isset ($ this ->parentTemplateObject ) || !is_a ($ this ->parentTemplateObject , "Repository " )) {
329
- $ this ->parentTemplateObject = ConfService::getRepositoryById ($ this ->parentId );
327
+ if (isSet ($ this ->inferOptionsFromParent ) && isSet ($ this ->parentId )){
328
+ $ parentTemplateObject = ConfService::getRepositoryById ($ this ->parentId );
329
+ if (empty ($ parentTemplateObject ) || !is_a ($ parentTemplateObject , "Repository " )) {
330
+ throw new Exception ("Option should be loaded from parent repository, but it was not found " );
330
331
}
331
- if (isSet ($ this ->parentTemplateObject )) {
332
- $ value = $ this ->parentTemplateObject ->getOption ($ oName , $ safe );
332
+ }
333
+ if (!$ safe && $ this ->inferOptionsFromParent ) {
334
+ if (isSet ($ parentTemplateObject )) {
335
+ $ value = $ parentTemplateObject ->getOption ($ oName , $ safe );
333
336
if (is_string ($ value ) && strstr ($ value , "AJXP_ALLOW_SUB_PATH " ) !== false ) {
334
337
$ val = rtrim (str_replace ("AJXP_ALLOW_SUB_PATH " , "" , $ value ), "/ " )."/ " .$ this ->options [$ oName ];
335
338
return AJXP_Utils::securePath ($ val );
@@ -342,11 +345,11 @@ public function getOption($oName, $safe=false, $resolveUser = null)
342
345
return $ value ;
343
346
}
344
347
if ($ this ->inferOptionsFromParent ) {
345
- if (!isset ($ this -> parentTemplateObject )) {
346
- $ this -> parentTemplateObject = ConfService::getRepositoryById ($ this ->parentId );
348
+ if (!isset ($ parentTemplateObject )) {
349
+ $ parentTemplateObject = ConfService::getRepositoryById ($ this ->parentId );
347
350
}
348
- if (isSet ($ this -> parentTemplateObject )) {
349
- return $ this -> parentTemplateObject ->getOption ($ oName , $ safe );
351
+ if (isSet ($ parentTemplateObject )) {
352
+ return $ parentTemplateObject ->getOption ($ oName , $ safe );
350
353
}
351
354
}
352
355
return "" ;
0 commit comments