Commit:    4bea3f23a51acc259a5368d38a2696b395351f30
Author:    Hannes Magnusson <[email protected]>         Thu, 26 Dec 2013 
17:14:02 -0800
Parents:   ae8ead9dde45e358a3b6f7241df740dd8a1681ad
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=4bea3f23a51acc259a5368d38a2696b395351f30

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);


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to