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

Commit

Permalink
Performance: user queriesCache for exposed properties list
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jun 2, 2015
1 parent bdae799 commit 53d4800
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions core/src/plugins/core.conf/class.AbstractConfDriver.php
Expand Up @@ -517,20 +517,28 @@ public function getExposedPreferences($userObject)
$prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json" );
}

$paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true);
if (is_array($paramNodes) && count($paramNodes)) {
foreach ($paramNodes as $xmlNode) {
if ($xmlNode->getAttribute("expose") == "true") {
$parentNode = $xmlNode->parentNode->parentNode;
$pluginId = $parentNode->getAttribute("id");
if (empty($pluginId)) {
$pluginId = $parentNode->nodeName.".".$parentNode->getAttribute("name");
}
$name = $xmlNode->getAttribute("name");
$value = $userObject->mergedRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "");
$prefs[$name] = array("value" => $value, "type" => "string", "pluginId" => $pluginId);

$exposed = array();
$cacheHasExposed = AJXP_PluginsService::getInstance()->loadFromPluginQueriesCache("//server_settings/param[contains(@scope,'user') and @expose='true']");
if ($cacheHasExposed !== null && is_array($cacheHasExposed)) {
$exposed = $cacheHasExposed;
} else {
$exposed_props = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true);
foreach($exposed_props as $exposed_prop){
$parentNode = $exposed_prop->parentNode->parentNode;
$pluginId = $parentNode->getAttribute("id");
if (empty($pluginId)) {
$pluginId = $parentNode->nodeName.".".$parentNode->getAttribute("name");
}
$paramName = $exposed_prop->getAttribute("name");
$exposed[] = array("PLUGIN_ID" => $pluginId, "NAME" => $paramName);
}
AJXP_PluginsService::getInstance()->storeToPluginQueriesCache("//server_settings/param[contains(@scope,'user') and @expose='true']", $exposed);
}

foreach ($exposed as $exposedProp) {
$value = $userObject->mergedRole->filterParameterValue($exposedProp["PLUGIN_ID"], $exposedProp["NAME"], AJXP_REPO_SCOPE_ALL, "");
$prefs[$exposedProp["NAME"]] = array("value" => $value, "type" => "string", "pluginId" => $exposedProp["PLUGIN_ID"]);
}

return $prefs;
Expand Down Expand Up @@ -617,7 +625,16 @@ public function switchAction($action, $httpVars, $fileVars)
echo json_encode($data);
}else{
header('Content-Type: application/xml; charset=UTF-8');
print(AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML()));
$string = AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
$etag = md5($string);
$match = isSet($_SERVER["HTTP_IF_NONE_MATCH"])?$_SERVER["HTTP_IF_NONE_MATCH"]:'';
if($match == $etag){
header('HTTP/1.1 304 Not Modified');
}else{
header('Cache-Control:public, max-age=31536000');
header('ETag: '.$etag);
print($string);
}
}
}

Expand Down

0 comments on commit 53d4800

Please sign in to comment.