com web/php: Cache manual pages. Fixes bug #55584: include/header.inc include/shared-manual.inc
| From: | Hannes Magnusson | Date: | Fri, 27 Dec 2013 01:14:02 +0000 |
| Subject: | com web/php: Cache manual pages. Fixes bug #55584: include/header.inc include/shared-manual.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17809@lists.php.net to get a copy of this message | ||
Commit: f237cd07bfa914a40eaee6db199a20766f3d097a
Author: Hannes Magnusson <bjori@mongodb.com> Thu, 26 Dec 2013 17:14:02 -0800
Parents: ef1389c73d9f19623338a603c904b1a4a69f1734
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=f237cd07bfa914a40eaee6db199a20766f3d097a
Log:
Cache manual pages. Fixes bug #55584
Bugs:
https://bugs.php.net/55584
Changed paths:
M include/header.inc
M include/shared-manual.inc
Diff:
diff --git a/include/header.inc b/include/header.inc
index 4b4e945..c015d5d 100755
--- a/include/header.inc
+++ b/include/header.inc
@@ -15,7 +15,11 @@ if (isset($shortname) && $shortname) {
}
if ($config["cache"]) {
- $timestamp = filemtime($_SERVER["DOCUMENT_ROOT"] . "/"
.$_SERVER["BASE_PAGE"]);
+ if (is_numeric($config["cache"])) {
+ $timestamp = $config["cache"];
+ } else {
+ $timestamp = filemtime($_SERVER["DOCUMENT_ROOT"] . "/"
.$_SERVER["BASE_PAGE"]);
+ }
$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT";
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) &&
$_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring) {
diff --git a/include/shared-manual.inc b/include/shared-manual.inc
index 76132bc..f253ae5 100644
--- a/include/shared-manual.inc
+++ b/include/shared-manual.inc
@@ -138,7 +138,7 @@ class ManualNotesSorter {
// Print out all user notes for this manual page
-function manual_notes() {
+function manual_notes($notes) {
// Get needed values
list($filename, $title) = $GLOBALS['PGI']['this'];
@@ -147,9 +147,6 @@ function manual_notes() {
$filename = substr($filename, 0, -4);
}
- // Load user note for this page
- $notes = manual_notes_load($filename);
-
$sorter = new ManualNotesSorter;
$sorter->sort($notes);
@@ -320,12 +317,24 @@ USER_NOTE_TEXT;
// Set up variables important for this page
// including HTTP header information
function manual_setup($setup) {
- global $PGI, $MYSITE;
+ global $PGI, $MYSITE, $USERNOTES;
+
$PGI = $setup;
// Set base href for this manual page
$_SERVER['BASE_PAGE'] = 'manual/' .
language_convert($setup['head'][1]) . "/" . $setup['this'][0];
$_SERVER['BASE_HREF'] = $MYSITE . $_SERVER['BASE_PAGE'];
+ // Load user note for this page
+ list($filename, $title) = $PGI['this'];
+
+ // Drop file extension from the name
+ if (substr($filename, -4) == '.php') {
+ $filename = substr($filename, 0, -4);
+ }
+ $USERNOTES = manual_notes_load($filename);
+ $note = current($USERNOTES);
+ $lastusernote = $note["xwhen"];
+
$siblings = array();
foreach($setup["toc"] as $entry) {
@@ -363,6 +372,8 @@ function manual_setup($setup) {
$base = "manual/" . $setup["head"][1] . "/";
$_SERVER["BASE_PAGE"] = "/" . $base . $setup["this"][0];
+ $f = $_SERVER["DOCUMENT_ROOT"] . $_SERVER["BASE_PAGE"];
+ $lastmod = max(filemtime($f), $lastusernote);
$config = array(
"current" => "docs",
@@ -378,6 +389,7 @@ function manual_setup($setup) {
"thispage" => $setup["this"][0],
"prev" => $setup["prev"],
"next" => $setup["next"],
+ "cache" => $lastmod,
);
site_header($setup["this"][1] . " - Manual ", $config);
@@ -423,8 +435,9 @@ function manual_language_chooser($currentlang, $currentpage) {
function manual_header(){}
function manual_footer() {
+ global $USERNOTES;
- manual_notes();
+ manual_notes($USERNOTES);
echo "</section>";
$config = array();
site_footer($config);