[pmwiki-users] pmwiki.php: Array and string offset access syntax with curly braces is deprecated
Petko Yotov
5ko at 5ko.fr
Tue May 4 21:30:57 PDT 2021
Thank you for the message and the diffs but this has already been fixed
this was fixed in 2.2.119 (2019-10-03), that is 19 months ago and 19
versions released since then:
https://www.pmwiki.org/wiki/PmWiki/ChangeLog#v22119
You must have started from a fairly old version (also the line numbers
are way off, like 188 lines of code missing against the dev snapshot, so
there may be other stuff wrong or missing).
You can see which version and which date you started from by looking in
your copy of pmwiki.php, the top comment block, there is a line like:
$Id: pmwiki.php 3699 2021-02-26 19:08:16Z petko $
That is the line from version 2.2.138.
Otherwise, look in in scripts/version.php.
If you can upgrade your installation to the most recent core version, it
may save you quite some work, work which we may have already done.
Bug reports and diffs are always welcome -- when possible against the
latest version, or against the latest development snapshot.
Petko
On 05/05/2021 05:34, T. Michael Sommers wrote:
> I have a brand new installation of pmwiki, from a tarball downloaded a
> few weeks ago. I am using php 7.4.3 on FreeBSD 11.2-RELEASE-p3. I
> get a lot of warnings saying, "Array and string offset access syntax
> with curly braces is deprecated" for pmwiki.php.
>
> This is a diff that fixes them:
>
> --- snip ---
> --- pmwiki.php.orig 2021-05-04 23:00:53.048909000 -0400
> +++ pmwiki.php 2021-05-04 23:25:24.454431000 -0400
> @@ -703,7 +703,7 @@
> array('.*', '.', '[', ']', '^', '-', '!'),
> $pat);
> $excl = array(); $incl = array();
> foreach(preg_split('/,+\s?/', $pat, -1, PREG_SPLIT_NO_EMPTY) as $p)
> {
> - if ($p{0} == '-' || $p{0} == '!') $excl[] = '^'.substr($p, 1).'$';
> + if ($p[0] == '-' || $p[0] == '!') $excl[] = '^'.substr($p, 1).'$';
> else $incl[] = "^$p$";
> }
> return array(implode('|', $incl), implode('|', $excl));
> @@ -733,7 +733,7 @@
> foreach((array)$pat as $p) {
> if (count($pagelist) < 1) break;
> if (!$p) continue;
> - switch ($p{0}) {
> + switch ($p[0]) {
> case '/':
> $pagelist = preg_grep($p, $pagelist);
> break;
> @@ -1009,7 +1009,7 @@
> foreach($a as $k=>$v) {
> if (!isset($XL[$lang][$k])) {
> if (preg_match('/^e_(rows|cols)$/', $k)) $v = intval($v);
> - elseif (preg_match('/^ak_/', $k)) $v = $v{0};
> + elseif (preg_match('/^ak_/', $k)) $v = $v[0];
> $XL[$lang][$k]=$v;
> }
> }
> @@ -1151,7 +1151,7 @@
> $x = "version=$Version ordered=1 urlencoded=1\n";
> $s = true && fputs($fp, $x); $sz = strlen($x);
> foreach($page as $k=>$v)
> - if ($k > '' && $k{0} != '=') {
> + if ($k > '' && $k[0] != '=') {
> $x = str_replace($r0, $r1, "$k=$v") . "\n";
> $s = $s && fputs($fp, $x); $sz += strlen($x);
> }
> @@ -1192,7 +1192,7 @@
> $dirslash = substr_count($dir, '/') + 1;
> $o = array();
> while ( ($pagefile = readdir($dfp)) !== false) {
> - if ($pagefile{0} == '.') continue;
> + if ($pagefile[0] == '.') continue;
> if ($dirslash < $maxslash && is_dir("$dir/$pagefile"))
> { array_push($dirlist,"$dir/$pagefile"); continue; }
> if ($dirslash == $maxslash) $o[] = $this->PFD($pagefile);
> @@ -1441,7 +1441,7 @@
> ## The caller is responsible for calling Qualify() as needed.
> function RetrieveAuthSection($pagename, $pagesection, $list=NULL,
> $auth='read') {
> global $RASPageName, $PCache;
> - if ($pagesection{0} != '#')
> + if ($pagesection[0] != '#')
> $list = array(MakePageName($pagename, $pagesection));
> else if (is_null($list)) $list = array($pagename);
> foreach((array)$list as $t) {
> @@ -1465,7 +1465,7 @@
> while (count($args['#'])>0) {
> $k = array_shift($args['#']); $v = array_shift($args['#']);
> if ($k=='') {
> - if ($v{0} != '#') {
> + if ($v[0] != '#') {
> if (isset($itext)) continue;
> $iname = MakePageName($pagename, $v);
> if (!$args['self'] && $iname == $pagename) continue;
> @@ -1478,7 +1478,7 @@
> if (preg_match('/^(?:line|para)s?$/', $k)) {
> preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
> @list($x, $a, $dots, $b) = $match;
> - $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
> + $upat = ($k[0] == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
> if (!$dots) { $b=$a; $a=0; }
> if ($a>0) $a--;
> $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
> @@ -1640,7 +1640,7 @@
> $suffix = $txt[1];
> $txt = $txt[0];
> }
> - if (!$fmt && $path{0} == '#') {
> + if (!$fmt && $path[0] == '#') {
> $path = preg_replace("/[^-.:\\w]/", '', $path);
> if (trim($txt) == '+') $txt = PageVar($pagename, '$Title') .
> @$suffix;
> if ($alt) $alt = " title='$alt'";
> @@ -1785,7 +1785,7 @@
> foreach($markrules as $p=>$r) {
> list($r, $id) = (array)$r;
> $MarkupToHTML['markupid'] = $id;
> - if ($p{0} == '/') {
> + if ($p[0] == '/') {
> if (is_callable($r)) $x = preg_replace_callback($p,$r,$x);
> else $x=preg_replace($p,$r,$x);
> }
> @@ -2209,11 +2209,11 @@
> if ($pw == ',' || $pw == '') continue;
> else if ($pw == ' ') { $x = ''; continue; }
> else if (substr($pw, -1, 1) == ':') { $x = $pw; continue; }
> - else if ($pw{0} != '@' && $x > '') $pw = $x . $pw;
> + else if ($pw[0] != '@' && $x > '') $pw = $x . $pw;
> if (!$pw) continue;
> $passwd[] = $pw;
> if ($auth < 0) continue;
> - if ($x || $pw{0} == '@') {
> + if ($x || $pw[0] == '@') {
> if (@$AuthList[$pw]) $auth = $AuthList[$pw];
> continue;
> }
> --- snip ---
More information about the pmwiki-users
mailing list