• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revision496d9253e9032fa29bc4d9425883716372c0f7e2 (tree)
Time2018-05-29 00:02:46
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2472 Improve Edit - template list response

Fix slow processing of generating template page list
on large scale - which have many pages - site.

Change Summary

Incremental Difference

--- a/en.lng.php
+++ b/en.lng.php
@@ -2,7 +2,7 @@
22 // PukiWiki - Yet another WikiWikiWeb clone.
33 // en.lng.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 //
@@ -79,7 +79,6 @@ $_btn_template = 'Use page as template';
7979 $_btn_load = 'Load';
8080 $_btn_edit = 'Edit';
8181 $_btn_delete = 'Delete';
82-$_label_template_pages = 'Template pages';
8382
8483 ///////////////////////////////////////
8584 // Authentication
--- a/ja.lng.php
+++ b/ja.lng.php
@@ -2,7 +2,7 @@
22 // PukiWiki - Yet another WikiWikiWeb clone.
33 // ja.lng.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 //
@@ -81,7 +81,6 @@ $_btn_template = '雛形とするページ';
8181 $_btn_load = '読込';
8282 $_btn_edit = '編集';
8383 $_btn_delete = '削除';
84-$_label_template_pages = 'テンプレートページ';
8584
8685 ///////////////////////////////////////
8786 // Authentication
--- a/lib/html.php
+++ b/lib/html.php
@@ -317,7 +317,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
317317 global $_btn_preview, $_btn_repreview, $_btn_update, $_btn_cancel, $_msg_help;
318318 global $whatsnew, $_btn_template, $_btn_load, $load_template_func;
319319 global $notimeupdate;
320- global $_title_list, $_label_template_pages;
320+ global $_title_list;
321321 global $_msg_edit_cancel_confirm, $_msg_edit_unloadbefore_message;
322322 global $rule_page;
323323
@@ -352,44 +352,41 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
352352 $tpage_names[] = $tpage;
353353 }
354354 $page_names = array();
355- foreach(get_existpages() as $_page) {
355+ $page_list = get_existpages();
356+ if (count($page_list) > $page_max) {
357+ // Extract only template name pages
358+ $target_pages = array();
359+ foreach ($page_list as $_page) {
360+ if (preg_match('/template/i', $_page)) {
361+ $target_pages[] = $_page;
362+ }
363+ }
364+ } else {
365+ $target_pages = $page_list;
366+ }
367+ foreach ($target_pages as $_page) {
356368 if ($_page == $whatsnew || check_non_list($_page) ||
357- !is_page_readable($_page))
369+ !is_page_readable($_page)) {
358370 continue;
359- if (preg_match('/template/i', $_page)) {
360- $tpage_names[] = $_page;
361- } else {
362- if (count($page_names) >= $page_max) continue;
363- $page_names[] = $_page;
364371 }
372+ $tpage_names[] = $_page;
365373 }
366374 $tpage_names2 = array_values(array_unique($tpage_names));
367375 natcasesort($tpage_names2);
368- natcasesort($page_names);
369376 $tpages = array(); // Template pages
370- $npages = array(); // Normal pages
371377 foreach($tpage_names2 as $p) {
372378 $ps = htmlsc($p);
373379 $tpages[] = ' <option value="' . $ps . '">' . $ps . '</option>';
374380 }
375- foreach($page_names as $p) {
376- $ps = htmlsc($p);
377- $npages[] = ' <option value="' . $ps . '">' . $ps . '</option>';
378- }
379- if (count($page_names) === $page_max) {
380- $npages[] = ' <option value="">...</option>';
381+ if (count($tpage_names2) > 0) {
382+ $s_tpages = join("\n", $tpages);
383+ } else {
384+ $s_tpages = ' <option value="">(no template pages)</option>';
381385 }
382- $s_tpages = join("\n", $tpages);
383- $s_npages = join("\n", $npages);
384386 $template = <<<EOD
385387 <select name="template_page">
386388 <option value="">-- $_btn_template --</option>
387- <optgroup label="$_label_template_pages">
388389 $s_tpages
389- </optgroup>
390- <optgroup label="$_title_list">
391-$s_npages
392- </optgroup>
393390 </select>
394391 <input type="submit" name="template" value="$_btn_load" accesskey="r" />
395392 <br />
Show on old repository browser