Révision | 3e9aff651100904644cab881b73940059cd7ab30 (tree) |
---|---|
l'heure | 2018-03-01 00:19:56 |
Auteur | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/560 Get timestamps of tracker_list pages from cache
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // func.php |
4 | 4 | // Copyright |
5 | -// 2002-2017 PukiWiki Development Team | |
5 | +// 2002-2018 PukiWiki Development Team | |
6 | 6 | // 2001-2002 Originally written by yu-ji |
7 | 7 | // License: GPL v2 or (at your option) any later version |
8 | 8 | // |
@@ -350,6 +350,27 @@ function get_page_link_a_attrs($page) | ||
350 | 350 | ); |
351 | 351 | } |
352 | 352 | |
353 | +/** | |
354 | + * Get page link general attributes from filetime | |
355 | + * @param $filetime | |
356 | + * @return array('data_mtime' => page mtime or null, 'class' => additinal classes) | |
357 | + */ | |
358 | +function get_filetime_a_attrs($filetime) | |
359 | +{ | |
360 | + global $show_passage; | |
361 | + if ($show_passage) { | |
362 | + $pagemtime = get_date_atom($filetime + LOCALZONE); | |
363 | + return array( | |
364 | + 'data_mtime' => $pagemtime, | |
365 | + 'class' => get_link_passage_class(), | |
366 | + ); | |
367 | + } | |
368 | + return array( | |
369 | + 'data_mtime' => '', | |
370 | + 'class' => '' | |
371 | + ); | |
372 | +} | |
373 | + | |
353 | 374 | // 'Search' main function |
354 | 375 | function do_search($word, $type = 'AND', $non_format = FALSE, $base = '') |
355 | 376 | { |
@@ -2,12 +2,29 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // make_link.php |
4 | 4 | // Copyright |
5 | -// 2003-2017 PukiWiki Development Team | |
5 | +// 2003-2018 PukiWiki Development Team | |
6 | 6 | // 2001-2002 Originally written by yu-ji |
7 | 7 | // License: GPL v2 or (at your option) any later version |
8 | 8 | // |
9 | 9 | // Hyperlink-related functions |
10 | 10 | |
11 | +// To get page exists or filetimes without accessing filesystem | |
12 | +// Type: array (page => filetime) | |
13 | +$_cached_page_filetime = null; | |
14 | + | |
15 | +// Get filetime from cache | |
16 | +function fast_get_filetime($page) | |
17 | +{ | |
18 | + global $_cached_page_filetime; | |
19 | + if (is_null($_cached_page_filetime)) { | |
20 | + return get_filetime($page); | |
21 | + } | |
22 | + if (isset($_cached_page_filetime[$page])) { | |
23 | + return $_cached_page_filetime[$page]; | |
24 | + } | |
25 | + return get_filetime($page); | |
26 | +} | |
27 | + | |
11 | 28 | // Hyperlink decoration |
12 | 29 | function make_link($string, $page = '') |
13 | 30 | { |
@@ -763,12 +780,14 @@ function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolin | ||
763 | 780 | $r_page = pagename_urlencode($page); |
764 | 781 | $r_refer = ($refer == '') ? '' : '&refer=' . rawurlencode($refer); |
765 | 782 | |
766 | - if (! isset($related[$page]) && $page !== $vars['page'] && is_page($page)) | |
767 | - $related[$page] = get_filetime($page); | |
783 | + $page_filetime = fast_get_filetime($page); | |
784 | + $is_page = $page_filetime !== 0; | |
785 | + if (! isset($related[$page]) && $page !== $vars['page'] && is_page) | |
786 | + $related[$page] = $page_filetime; | |
768 | 787 | |
769 | - if ($isautolink || is_page($page)) { | |
788 | + if ($isautolink || $is_page) { | |
770 | 789 | // Hyperlink to the page |
771 | - $attrs = get_page_link_a_attrs($page); | |
790 | + $attrs = get_filetime_a_attrs($page_filetime); | |
772 | 791 | // AutoLink marker |
773 | 792 | if ($isautolink) { |
774 | 793 | $al_left = '<!--autolink-->'; |
@@ -798,7 +798,7 @@ class Tracker_list | ||
798 | 798 | } |
799 | 799 | function __construct($page,$refer,&$config,$list,&$cache_holder) |
800 | 800 | { |
801 | - global $whatsdeleted; | |
801 | + global $whatsdeleted, $_cached_page_filetime; | |
802 | 802 | $this->page = $page; |
803 | 803 | $this->config = &$config; |
804 | 804 | $this->list = $list; |
@@ -976,6 +976,11 @@ class Tracker_list | ||
976 | 976 | } |
977 | 977 | $this->link_pages = $new_link_pages; |
978 | 978 | $this->link_update_required = $link_update_required; |
979 | + $time_map_for_cache = $new_link_map; | |
980 | + foreach ($this->rows as $row) { | |
981 | + $time_map_for_cache[$this->page . '/' . $row['_real']] = $row['_update']; | |
982 | + } | |
983 | + $_cached_page_filetime = $time_map_for_cache; | |
979 | 984 | } |
980 | 985 | } |
981 | 986 | function decode_cached_rows($decoded_rows) |