コミットメタ情報

リビジョン75163cb51f5dd179e1f677c281ec9ec3063ba973 (tree)
日時2018-03-01 00:19:56
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/560 Get timestamps of tracker_list pages from cache

変更サマリ

差分

--- a/lib/func.php
+++ b/lib/func.php
@@ -2,7 +2,7 @@
22 // PukiWiki - Yet another WikiWikiWeb clone.
33 // func.php
44 // Copyright
5-// 2002-2017 PukiWiki Development Team
5+// 2002-2018 PukiWiki Development Team
66 // 2001-2002 Originally written by yu-ji
77 // License: GPL v2 or (at your option) any later version
88 //
@@ -350,6 +350,27 @@ function get_page_link_a_attrs($page)
350350 );
351351 }
352352
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+
353374 // 'Search' main function
354375 function do_search($word, $type = 'AND', $non_format = FALSE, $base = '')
355376 {
--- a/lib/make_link.php
+++ b/lib/make_link.php
@@ -2,12 +2,29 @@
22 // PukiWiki - Yet another WikiWikiWeb clone.
33 // make_link.php
44 // Copyright
5-// 2003-2017 PukiWiki Development Team
5+// 2003-2018 PukiWiki Development Team
66 // 2001-2002 Originally written by yu-ji
77 // License: GPL v2 or (at your option) any later version
88 //
99 // Hyperlink-related functions
1010
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+
1128 // Hyperlink decoration
1229 function make_link($string, $page = '')
1330 {
@@ -763,12 +780,14 @@ function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolin
763780 $r_page = pagename_urlencode($page);
764781 $r_refer = ($refer == '') ? '' : '&amp;refer=' . rawurlencode($refer);
765782
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;
768787
769- if ($isautolink || is_page($page)) {
788+ if ($isautolink || $is_page) {
770789 // Hyperlink to the page
771- $attrs = get_page_link_a_attrs($page);
790+ $attrs = get_filetime_a_attrs($page_filetime);
772791 // AutoLink marker
773792 if ($isautolink) {
774793 $al_left = '<!--autolink-->';
--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -798,7 +798,7 @@ class Tracker_list
798798 }
799799 function __construct($page,$refer,&$config,$list,&$cache_holder)
800800 {
801- global $whatsdeleted;
801+ global $whatsdeleted, $_cached_page_filetime;
802802 $this->page = $page;
803803 $this->config = &$config;
804804 $this->list = $list;
@@ -976,6 +976,7 @@ class Tracker_list
976976 }
977977 $this->link_pages = $new_link_pages;
978978 $this->link_update_required = $link_update_required;
979+ $_cached_page_filetime = $new_link_map;
979980 }
980981 }
981982 function decode_cached_rows($decoded_rows)
旧リポジトリブラウザで表示