Revision | a6cac21c76c2e94d8b90a26a59764b7e0e4cfb81 (tree) |
---|---|
Zeit | 2021-03-13 15:14:30 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2514 Support PHP 8
PHP8 - Backward Incompatible Changes
* Support for deprecated curly braces for offset access has been removed
* Fatal error: Inheritance errors due to incompatible method signatures
* get_magic_quotes_gpc() have been removed
* Fatal error: Undefined constant ( is_page )
* Nested ternaries now require explicit parentheses
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // config.php |
4 | -// Copyright 2003-2016 PukiWiki Development Team | |
4 | +// Copyright 2003-2021 PukiWiki Development Team | |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
7 | 7 | // Parse a PukiWiki page as a configuration page |
@@ -49,7 +49,7 @@ class Config | ||
49 | 49 | foreach (get_source($this->page) as $line) { |
50 | 50 | if ($line == '') continue; |
51 | 51 | |
52 | - $head = $line{0}; // The first letter | |
52 | + $head = $line[0]; // The first letter | |
53 | 53 | $level = strspn($line, $head); |
54 | 54 | |
55 | 55 | if ($level > 3) { |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // convert_html.php |
4 | 4 | // Copyright |
5 | -// 2002-2016 PukiWiki Development Team | |
5 | +// 2002-2021 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 | // |
@@ -64,7 +64,7 @@ class Element | ||
64 | 64 | return $this->last = & $obj->last; |
65 | 65 | } |
66 | 66 | |
67 | - function canContain($obj) | |
67 | + function canContain(& $obj) | |
68 | 68 | { |
69 | 69 | return TRUE; |
70 | 70 | } |
@@ -186,7 +186,7 @@ class Inline extends Element | ||
186 | 186 | return $this; |
187 | 187 | } |
188 | 188 | |
189 | - function canContain($obj) | |
189 | + function canContain(& $obj) | |
190 | 190 | { |
191 | 191 | return is_a($obj, 'Inline'); |
192 | 192 | } |
@@ -226,7 +226,7 @@ class Paragraph extends Element | ||
226 | 226 | $this->insert(Factory_Inline($text)); |
227 | 227 | } |
228 | 228 | |
229 | - function canContain($obj) | |
229 | + function canContain(& $obj) | |
230 | 230 | { |
231 | 231 | return is_a($obj, 'Inline'); |
232 | 232 | } |
@@ -531,7 +531,7 @@ class TableCell extends Element | ||
531 | 531 | $name = $matches[2] ? 'background-color' : 'color'; |
532 | 532 | $this->style[$name] = $name . ':' . htmlsc($matches[3]) . ';'; |
533 | 533 | $text = $matches[5]; |
534 | - } else if ($matches[4]) { | |
534 | + } else if (isset($matches[4])) { | |
535 | 535 | $this->style['size'] = 'font-size:' . htmlsc($matches[4]) . 'px;'; |
536 | 536 | $text = $matches[5]; |
537 | 537 | } |
@@ -548,7 +548,7 @@ class TableCell extends Element | ||
548 | 548 | $text = substr($text, 1); |
549 | 549 | } |
550 | 550 | |
551 | - if ($text != '' && $text{0} == '#') { | |
551 | + if ($text != '' && $text[0] == '#') { | |
552 | 552 | // Try using Div class for this $text |
553 | 553 | $obj = & Factory_Div($this, $text); |
554 | 554 | if (is_a($obj, 'Paragraph')) |
@@ -788,7 +788,7 @@ class Pre extends Element | ||
788 | 788 | global $preformat_ltrim; |
789 | 789 | parent::__construct(); |
790 | 790 | $this->elements[] = htmlsc( |
791 | - (! $preformat_ltrim || $text == '' || $text{0} != ' ') ? $text : substr($text, 1)); | |
791 | + (! $preformat_ltrim || $text == '' || $text[0] != ' ') ? $text : substr($text, 1)); | |
792 | 792 | } |
793 | 793 | |
794 | 794 | function canContain(& $obj) |
@@ -941,7 +941,7 @@ class Body extends Element | ||
941 | 941 | } |
942 | 942 | |
943 | 943 | // The first character |
944 | - $head = $line{0}; | |
944 | + $head = $line[0]; | |
945 | 945 | |
946 | 946 | // Heading |
947 | 947 | if ($head == '*') { |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // file.php |
4 | 4 | // Copyright |
5 | -// 2002-2020 PukiWiki Development Team | |
5 | +// 2002-2021 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 | // |
@@ -160,7 +160,7 @@ function make_str_rules($source) | ||
160 | 160 | $line = & $lines[$i]; // Modify directly |
161 | 161 | |
162 | 162 | // Ignore null string and preformatted texts |
163 | - if ($line == '' || $line{0} == ' ' || $line{0} == "\t") continue; | |
163 | + if ($line == '' || $line[0] == ' ' || $line[0] == "\t") continue; | |
164 | 164 | |
165 | 165 | // Modify this line? |
166 | 166 | if ($modify) { |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // func.php |
4 | 4 | // Copyright |
5 | -// 2002-2020 PukiWiki Development Team | |
5 | +// 2002-2021 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 | // |
@@ -1039,9 +1039,14 @@ function guess_script_absolute_uri() | ||
1039 | 1039 | function input_filter($param) |
1040 | 1040 | { |
1041 | 1041 | static $magic_quotes_gpc = NULL; |
1042 | - if ($magic_quotes_gpc === NULL) | |
1043 | - $magic_quotes_gpc = get_magic_quotes_gpc(); | |
1044 | - | |
1042 | + if ($magic_quotes_gpc === NULL) { | |
1043 | + if (function_exists('get_magic_quotes_gpc')) { | |
1044 | + // No 'get_magic_quotes_gpc' function in PHP8 | |
1045 | + $magic_quotes_gpc = get_magic_quotes_gpc(); | |
1046 | + } else { | |
1047 | + $magic_quotes_gpc = 0; | |
1048 | + } | |
1049 | + } | |
1045 | 1050 | if (is_array($param)) { |
1046 | 1051 | return array_map('input_filter', $param); |
1047 | 1052 | } else { |
@@ -1068,7 +1073,7 @@ function csv_explode($separator, $string) | ||
1068 | 1073 | |
1069 | 1074 | foreach ($matches[1] as $str) { |
1070 | 1075 | $len = strlen($str); |
1071 | - if ($len > 1 && $str{0} == '"' && $str{$len - 1} == '"') | |
1076 | + if ($len > 1 && $str[0] == '"' && $str[$len - 1] == '"') | |
1072 | 1077 | $str = str_replace('""', '"', substr($str, 1, -1)); |
1073 | 1078 | $retval[] = $str; |
1074 | 1079 | } |
@@ -1078,7 +1083,7 @@ function csv_explode($separator, $string) | ||
1078 | 1083 | // Implode an array with CSV data format (escape double quotes) |
1079 | 1084 | function csv_implode($glue, $pieces) |
1080 | 1085 | { |
1081 | - $_glue = ($glue != '') ? '\\' . $glue{0} : ''; | |
1086 | + $_glue = ($glue != '') ? '\\' . $glue[0] : ''; | |
1082 | 1087 | $arr = array(); |
1083 | 1088 | foreach ($pieces as $str) { |
1084 | 1089 | if (preg_match('/[' . '"' . "\n\r" . $_glue . ']/', $str)) |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // make_link.php |
4 | 4 | // Copyright |
5 | -// 2003-2020 PukiWiki Development Team | |
5 | +// 2003-2021 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 | // |
@@ -851,8 +851,9 @@ function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolin | ||
851 | 851 | |
852 | 852 | $page_filetime = fast_get_filetime($page); |
853 | 853 | $is_page = $page_filetime !== 0; |
854 | - if (! isset($related[$page]) && $page !== $vars['page'] && is_page) | |
854 | + if (! isset($related[$page]) && $page !== $vars['page'] && $is_page) { | |
855 | 855 | $related[$page] = $page_filetime; |
856 | + } | |
856 | 857 | |
857 | 858 | if ($isautolink || $is_page) { |
858 | 859 | // Hyperlink to the page |
@@ -905,7 +906,7 @@ function get_fullname($name, $refer) | ||
905 | 906 | if ($name == '' || $name == './') return $refer; |
906 | 907 | |
907 | 908 | // Absolute path |
908 | - if ($name{0} == '/') { | |
909 | + if ($name[0] == '/') { | |
909 | 910 | $name = substr($name, 1); |
910 | 911 | return ($name == '') ? $defaultpage : $name; |
911 | 912 | } |
@@ -1024,7 +1025,7 @@ function get_ticketlink_jira_projects() | ||
1024 | 1025 | } else if (preg_match('/^--\s*([A-Z][A-Z0-9]{1,10}(?:_[A-Z0-9]{1,10}){0,2})(\s+(.+?))?\s*$/', $line, $m)) { |
1025 | 1026 | if ($active_jira_base_url) { |
1026 | 1027 | $project_key = $m[1]; |
1027 | - $title = $m[2]; | |
1028 | + $title = isset($m[2]) ? $m[2] : ''; | |
1028 | 1029 | array_push($jira_projects, array( |
1029 | 1030 | 'key' => $m[1], |
1030 | 1031 | 'title' => $title, |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // plugin.php |
4 | 4 | // Copyright |
5 | -// 2002-2016 PukiWiki Development Team | |
5 | +// 2002-2021 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 | // |
@@ -51,20 +51,35 @@ function exist_plugin($name) | ||
51 | 51 | |
52 | 52 | // Check if plugin API 'action' exists |
53 | 53 | function exist_plugin_action($name) { |
54 | - return function_exists('plugin_' . $name . '_action') ? TRUE : exist_plugin($name) ? | |
55 | - function_exists('plugin_' . $name . '_action') : FALSE; | |
54 | + if (function_exists('plugin_' . $name . '_action')) { | |
55 | + return TRUE; | |
56 | + } | |
57 | + if (exist_plugin($name)) { | |
58 | + return function_exists('plugin_' . $name . '_action'); | |
59 | + } | |
60 | + return FALSE; | |
56 | 61 | } |
57 | 62 | |
58 | 63 | // Check if plugin API 'convert' exists |
59 | 64 | function exist_plugin_convert($name) { |
60 | - return function_exists('plugin_' . $name . '_convert') ? TRUE : exist_plugin($name) ? | |
61 | - function_exists('plugin_' . $name . '_convert') : FALSE; | |
65 | + if (function_exists('plugin_' . $name . '_convert')) { | |
66 | + return TRUE; | |
67 | + } | |
68 | + if (exist_plugin($name)) { | |
69 | + return function_exists('plugin_' . $name . '_convert'); | |
70 | + } | |
71 | + return FALSE; | |
62 | 72 | } |
63 | 73 | |
64 | 74 | // Check if plugin API 'inline' exists |
65 | 75 | function exist_plugin_inline($name) { |
66 | - return function_exists('plugin_' . $name . '_inline') ? TRUE : exist_plugin($name) ? | |
67 | - function_exists('plugin_' . $name . '_inline') : FALSE; | |
76 | + if (function_exists('plugin_' . $name . '_inline')) { | |
77 | + return TRUE; | |
78 | + } | |
79 | + if (exist_plugin($name)) { | |
80 | + return function_exists('plugin_' . $name . '_inline'); | |
81 | + } | |
82 | + return FALSE; | |
68 | 83 | } |
69 | 84 | |
70 | 85 | // Call 'init' function for the plugin |
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // proxy.php |
4 | -// Copyright: 2003-2017 PukiWiki Development Team | |
4 | +// Copyright: 2003-2021 PukiWiki Development Team | |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
7 | 7 | // HTTP-Proxy related functions |
@@ -130,7 +130,7 @@ function pkwk_http_request($url, $method = 'GET', $headers = '', $post = array() | ||
130 | 130 | $url = trim($matches[1]); |
131 | 131 | if (! preg_match('/^https?:\//', $url)) { |
132 | 132 | // Relative path to Absolute |
133 | - if ($url{0} != '/') | |
133 | + if ($url[0] != '/') | |
134 | 134 | $url = substr($url_path, 0, strrpos($url_path, '/')) . '/' . $url; |
135 | 135 | $url = $url_base . $url; // Add sheme, host |
136 | 136 | } |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // dump.inc.php |
4 | 4 | // Copyright |
5 | -// 2004-2017 PukiWiki Development Team | |
5 | +// 2004-2021 PukiWiki Development Team | |
6 | 6 | // 2004 teanan / Interfair Laboratory |
7 | 7 | // License: GPL v2 or (at your option) any later version |
8 | 8 | // |
@@ -488,7 +488,7 @@ class tarlib | ||
488 | 488 | // ファイル名を保存 |
489 | 489 | for($i = 0; $i < strlen($filename); $i++ ) { |
490 | 490 | if ($i < TARLIB_HDR_NAME_LEN) { |
491 | - $tar_data[$i + TARLIB_HDR_NAME_OFFSET] = $filename{$i}; | |
491 | + $tar_data[$i + TARLIB_HDR_NAME_OFFSET] = $filename[$i]; | |
492 | 492 | } else { |
493 | 493 | break; // ファイル名が長すぎ |
494 | 494 | } |
@@ -497,32 +497,32 @@ class tarlib | ||
497 | 497 | // mode |
498 | 498 | $modeid = TARLIB_DATA_MODE; |
499 | 499 | for($i = 0; $i < strlen($modeid); $i++ ) { |
500 | - $tar_data[$i + TARLIB_HDR_MODE_OFFSET] = $modeid{$i}; | |
500 | + $tar_data[$i + TARLIB_HDR_MODE_OFFSET] = $modeid[$i]; | |
501 | 501 | } |
502 | 502 | |
503 | 503 | // uid / gid |
504 | 504 | $ugid = TARLIB_DATA_UGID; |
505 | 505 | for($i = 0; $i < strlen($ugid); $i++ ) { |
506 | - $tar_data[$i + TARLIB_HDR_UID_OFFSET] = $ugid{$i}; | |
507 | - $tar_data[$i + TARLIB_HDR_GID_OFFSET] = $ugid{$i}; | |
506 | + $tar_data[$i + TARLIB_HDR_UID_OFFSET] = $ugid[$i]; | |
507 | + $tar_data[$i + TARLIB_HDR_GID_OFFSET] = $ugid[$i]; | |
508 | 508 | } |
509 | 509 | |
510 | 510 | // サイズ |
511 | 511 | $strsize = sprintf('%11o', $size); |
512 | 512 | for($i = 0; $i < strlen($strsize); $i++ ) { |
513 | - $tar_data[$i + TARLIB_HDR_SIZE_OFFSET] = $strsize{$i}; | |
513 | + $tar_data[$i + TARLIB_HDR_SIZE_OFFSET] = $strsize[$i]; | |
514 | 514 | } |
515 | 515 | |
516 | 516 | // 最終更新時刻 |
517 | 517 | $strmtime = sprintf('%o', $mtime); |
518 | 518 | for($i = 0; $i < strlen($strmtime); $i++ ) { |
519 | - $tar_data[$i + TARLIB_HDR_MTIME_OFFSET] = $strmtime{$i}; | |
519 | + $tar_data[$i + TARLIB_HDR_MTIME_OFFSET] = $strmtime[$i]; | |
520 | 520 | } |
521 | 521 | |
522 | 522 | // チェックサム計算用のブランクを設定 |
523 | 523 | $chkblanks = TARLIB_DATA_CHKBLANKS; |
524 | 524 | for($i = 0; $i < strlen($chkblanks); $i++ ) { |
525 | - $tar_data[$i + TARLIB_HDR_CHKSUM_OFFSET] = $chkblanks{$i}; | |
525 | + $tar_data[$i + TARLIB_HDR_CHKSUM_OFFSET] = $chkblanks[$i]; | |
526 | 526 | } |
527 | 527 | |
528 | 528 | // タイプフラグ |
@@ -535,7 +535,7 @@ class tarlib | ||
535 | 535 | } |
536 | 536 | $strchksum = sprintf('%7o',$sum); |
537 | 537 | for($i = 0; $i < strlen($strchksum); $i++ ) { |
538 | - $tar_data[$i + TARLIB_HDR_CHKSUM_OFFSET] = $strchksum{$i}; | |
538 | + $tar_data[$i + TARLIB_HDR_CHKSUM_OFFSET] = $strchksum[$i]; | |
539 | 539 | } |
540 | 540 | |
541 | 541 | return $tar_data; |
@@ -615,8 +615,8 @@ class tarlib | ||
615 | 615 | $longname = ''; |
616 | 616 | } else { |
617 | 617 | for ($i = 0; $i < TARLIB_HDR_NAME_LEN; $i++ ) { |
618 | - if ($buff{$i + TARLIB_HDR_NAME_OFFSET} != "\0") { | |
619 | - $name .= $buff{$i + TARLIB_HDR_NAME_OFFSET}; | |
618 | + if ($buff[$i + TARLIB_HDR_NAME_OFFSET] != "\0") { | |
619 | + $name .= $buff[$i + TARLIB_HDR_NAME_OFFSET]; | |
620 | 620 | } else { |
621 | 621 | break; |
622 | 622 | } |
@@ -630,22 +630,22 @@ class tarlib | ||
630 | 630 | $checksum = ''; |
631 | 631 | $chkblanks = TARLIB_DATA_CHKBLANKS; |
632 | 632 | for ($i = 0; $i < TARLIB_HDR_CHKSUM_LEN; $i++ ) { |
633 | - $checksum .= $buff{$i + TARLIB_HDR_CHKSUM_OFFSET}; | |
634 | - $buff{$i + TARLIB_HDR_CHKSUM_OFFSET} = $chkblanks{$i}; | |
633 | + $checksum .= $buff[$i + TARLIB_HDR_CHKSUM_OFFSET]; | |
634 | + $buff[$i + TARLIB_HDR_CHKSUM_OFFSET] = $chkblanks[$i]; | |
635 | 635 | } |
636 | 636 | list($checksum) = sscanf('0' . trim($checksum), '%i'); |
637 | 637 | |
638 | 638 | // Compute checksum |
639 | 639 | $sum = 0; |
640 | 640 | for($i = 0; $i < TARLIB_BLK_LEN; $i++ ) { |
641 | - $sum += 0xff & ord($buff{$i}); | |
641 | + $sum += 0xff & ord($buff[$i]); | |
642 | 642 | } |
643 | 643 | if ($sum != $checksum) break; // Error |
644 | 644 | |
645 | 645 | // Size |
646 | 646 | $size = ''; |
647 | 647 | for ($i = 0; $i < TARLIB_HDR_SIZE_LEN; $i++ ) { |
648 | - $size .= $buff{$i + TARLIB_HDR_SIZE_OFFSET}; | |
648 | + $size .= $buff[$i + TARLIB_HDR_SIZE_OFFSET]; | |
649 | 649 | } |
650 | 650 | list($size) = sscanf('0' . trim($size), '%i'); |
651 | 651 |
@@ -656,12 +656,12 @@ class tarlib | ||
656 | 656 | // 最終更新時刻 |
657 | 657 | $strmtime = ''; |
658 | 658 | for ($i = 0; $i < TARLIB_HDR_MTIME_LEN; $i++ ) { |
659 | - $strmtime .= $buff{$i + TARLIB_HDR_MTIME_OFFSET}; | |
659 | + $strmtime .= $buff[$i + TARLIB_HDR_MTIME_OFFSET]; | |
660 | 660 | } |
661 | 661 | list($mtime) = sscanf('0' . trim($strmtime), '%i'); |
662 | 662 | |
663 | 663 | // タイプフラグ |
664 | -// $type = $buff{TARLIB_HDR_TYPE_OFFSET}; | |
664 | +// $type = $buff[TARLIB_HDR_TYPE_OFFSET]; | |
665 | 665 | |
666 | 666 | if ($name == TARLIB_DATA_LONGLINK) { |
667 | 667 | // LongLink |
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // tracker.inc.php |
4 | -// Copyright 2003-2020 PukiWiki Development Team | |
4 | +// Copyright 2003-2021 PukiWiki Development Team | |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
7 | 7 | // Issue tracker plugin (See Also bugtrack plugin) |
@@ -1236,7 +1236,7 @@ class Tracker_list | ||
1236 | 1236 | // Ignore empty line |
1237 | 1237 | continue; |
1238 | 1238 | } |
1239 | - $this->pipe = ($line{0} == '|' or $line{0} == ':'); | |
1239 | + $this->pipe = ($line[0] == '|' or $line[0] == ':'); | |
1240 | 1240 | $source .= preg_replace_callback('/\[([^\[\]]+)\]/',array(&$this,'replace_item'),$line); |
1241 | 1241 | } |
1242 | 1242 | } |