• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂9419fe8e5837c31e1ef58cd08b4a8fd2297f4806 (tree)
時間2007-09-09 09:57:57
作者henoheno <henoheno>
Commiterhenoheno

Log Message

* BugTrack/779: Static variables within class methods cause side effect if the class is not singleton => private class variables
* Corrected $limit default bug (1 => 0(unlimited))
* tracker_list_action(): enable $limit

Change Summary

差異

--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -1,6 +1,6 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone
3-// $Id: tracker.inc.php,v 1.46 2007-09-08 16:37:16 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.47 2007-09-09 00:57:57 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -70,7 +70,6 @@ function plugin_tracker_convert()
7070 } else {
7171 $to[] = $_to;
7272 }
73- $fields[$field]->dispose();
7473 unset($fields[$field]);
7574 }
7675
@@ -149,7 +148,6 @@ function plugin_tracker_action()
149148 foreach (array_keys($fields) as $field) {
150149 $from[] = '[' . $field . ']';
151150 $to[] = isset($_post[$field]) ? $fields[$field]->format_value($_post[$field]) : '';
152- $fields[$field]->dispose();
153151 unset($fields[$field]);
154152 }
155153
@@ -299,11 +297,6 @@ class Tracker_field
299297 {
300298 return $value; // Default: $value itself
301299 }
302-
303- // Release the resources
304- function dispose()
305- {
306- }
307300 }
308301
309302 class Tracker_field_text extends Tracker_field
@@ -450,6 +443,7 @@ class Tracker_field_file extends Tracker_field_format
450443 class Tracker_field_radio extends Tracker_field_format
451444 {
452445 var $sort_type = SORT_NUMERIC;
446+ var $_options = array();
453447
454448 function get_tag()
455449 {
@@ -481,29 +475,18 @@ class Tracker_field_radio extends Tracker_field_format
481475
482476 function get_value($value)
483477 {
484- static $options = array();
485-
486- if ($value === NULL) {
487- $options = array();
488- return NULL;
489- }
478+ $options = & $this->_options;
479+ $name = $this->name;
490480
491- if (! isset($options[$this->name])) {
492- $options[$this->name] = array_flip(
493- array_map(
494- create_function('$arr', 'return $arr[0];'),
495- $this->config->get($this->name)
496- )
481+ if (! isset($options[$name])) {
482+ $values = array_map(
483+ create_function('$array', 'return $array[0];'),
484+ $this->config->get($name)
497485 );
486+ $options[$name] = array_flip($values); // array('value0' => 0, 'value1' => 1, ...)
498487 }
499488
500- // Int or $value
501- return isset($options[$this->name][$value]) ? $options[$this->name][$value] : $value;
502- }
503-
504- function dispose()
505- {
506- $this->get_value(NULL);
489+ return isset($options[$name][$value]) ? $options[$name][$value] : $value;
507490 }
508491 }
509492
@@ -632,7 +615,7 @@ function plugin_tracker_list_convert()
632615 $page = $refer = isset($vars['page']) ? $vars['page'] : '';
633616 $order = '';
634617 $list = 'list';
635- $limit = NULL;
618+ $limit = 0;
636619
637620 // TODO: SHOW USAGE OR ERROR CLEARLY
638621 if (func_num_args()) {
@@ -662,16 +645,17 @@ function plugin_tracker_list_action()
662645 $config = isset($vars['config']) ? $vars['config'] : '';
663646 $list = isset($vars['list']) ? $vars['list'] : 'list';
664647 $order = isset($vars['order']) ? $vars['order'] : '_real:SORT_DESC';
648+ $limit = isset($vars['limit']) ? intval($vars['limit']) : 0;
665649
666650 $s_page = make_pagelink($page);
667651 return array(
668652 'msg' => plugin_tracker_message('msg_list'),
669653 'body'=> str_replace('$1', $s_page, plugin_tracker_message('msg_back')) .
670- plugin_tracker_list_render($page, $refer, $config, $list, $order)
654+ plugin_tracker_list_render($page, $refer, $config, $list, $order, $limit)
671655 );
672656 }
673657
674-function plugin_tracker_list_render($page, $refer, $config_name, $list, $order_commands = '', $limit = NULL)
658+function plugin_tracker_list_render($page, $refer, $config_name, $list, $order_commands = '', $limit = 0)
675659 {
676660 $config = new Config('plugin/tracker/' . $config_name);
677661 if (! $config->read()) {
@@ -688,7 +672,6 @@ function plugin_tracker_list_render($page, $refer, $config_name, $list, $order_c
688672 if ($result == FALSE) {
689673 $result = '#tracker_list: Pages under \'' . htmlspecialchars($page) . '/\' not found' . '<br />';
690674 }
691- $list->dispose();
692675
693676 return $result;
694677 }
@@ -705,6 +688,7 @@ class Tracker_list
705688 var $pattern_fields;
706689 var $rows;
707690 var $order;
691+ var $_added;
708692
709693 function Tracker_list($page, $refer, & $config, $list)
710694 {
@@ -716,6 +700,7 @@ class Tracker_list
716700 $this->pattern_fields = array();
717701 $this->rows = array();
718702 $this->order = array();
703+ $this->_added = array();
719704
720705 $pattern = plugin_tracker_get_source($config->page . '/page', TRUE);
721706 // TODO: if (is FALSE) OR file_exists()
@@ -749,16 +734,10 @@ class Tracker_list
749734
750735 function add($page, $name)
751736 {
752- static $done = array();
753-
754- if (isset($done[$page])) return;
755737
756- if ($page === NULL) {
757- $done = array();
758- return;
759- }
738+ if (isset($this->_added[$page])) return;
760739
761- $done[$page] = TRUE;
740+ $this->_added[$page] = TRUE;
762741
763742 $source = plugin_tracker_get_source($page);
764743
@@ -929,18 +908,22 @@ class Tracker_list
929908 '&list=' . $r_list . '&order=' . $r_order . ']]';
930909 }
931910
932- function toString($limit = 10)
911+ function toString($limit = 0)
933912 {
934913 if (empty($this->rows)) return FALSE;
935914
936- $limit = max(1, intval($limit));
937-
938915 $count = $_count = count($this->rows);
939- if ($limit != 0 && $count > $limit) {
940- $rows = array_slice($this->rows, 0, $limit);
941- $_count = count($rows);
916+
917+ if ($limit != 0) {
918+ $limit = max(1, intval($limit));
919+ if ($count > $limit) {
920+ $rows = array_slice($this->rows, 0, $limit);
921+ $_count = count($rows);
922+ } else {
923+ $rows = $this->rows;
924+ }
942925 } else {
943- $rows = $this->rows;
926+ $rows = $this->rows;
944927 }
945928
946929 $source = array();
@@ -979,12 +962,6 @@ class Tracker_list
979962
980963 return convert_html(implode('', $source));
981964 }
982-
983- function dispose()
984- {
985- $this->add(NULL, NULL);
986- return;
987- }
988965 }
989966
990967 function plugin_tracker_get_source($page, $join = FALSE)