[pmwiki-users] include order and ResolvePage
Dan Weber
webmaster at drwhosting.net
Fri Mar 9 07:51:45 CST 2007
A problem with my cookbook script AttachDelete was reported to me. The
problem was that under certain circumstances $pagename was not pointing
to the requested page. Strange enough the standard PmWiki upload
behavior worked properly, which served as template for mine.
So I found the problem and it has to do with the include orders of
scripts. The attachdel.php script is a cookbook and as such is included
through the local/config.php file. Unfortunately at the time the local
config file is being included the $pagename is not resolved yet. Looking
at pmwiki.php you see the following:
if (file_exists("$FarmD/local/farmconfig.php"))
include_once("$FarmD/local/farmconfig.php");
if (IsEnabled($EnableLocalConfig,1)) {
if (file_exists("$LocalDir/config.php"))
include_once("$LocalDir/config.php");
elseif (file_exists('config.php'))
include_once('config.php');
}
SDV($CurrentTime, strftime($TimeFmt, $Now));
SDV($CurrentTimeISO, strftime($TimeISOFmt, $Now));
if (IsEnabled($EnableStdConfig,1))
include_once("$FarmD/scripts/stdconfig.php");
And in stdconfig.php you see this
$pagename = ResolvePageName($pagename);
So the $pagename is resolved before any of the standard scripts,
including the upload script, are included and they work correctly.
As a fix I can make a call to ResolvePage in my cookbook script but for
a while I was wondering if maybe the ResolvePage should be done before
the local config is included, so that all cookbook recipes get the
proper value. But now I am thinking that some of the config variables in
the local config file may need to take place BEFORE the ResolvePage
(default page and group name definitions for instance), so this would
not work?
Maybe the configuration should be broken apart. Have local/config.php
just do configuration and then define a local/cookbook.php file that
just does the configuration and inclusion of cookbook script. Then in
pmwiki.php do the inclusion of the local/config.php, then do a
ResolvePage, then include local/cookbook.php and then include stdconfig.php.
Did anyone else come across this issue before as well? How did you
resolve it? For now the fix to call ResolvePage from within my cookbook
script works, I am just looking if there is a better way to resolve the
issue in a more general way.
Thanks
Dan
More information about the pmwiki-users
mailing list