Issue:Split() is deprecated

From FollowTheScore
Jump to: navigation, search
Description: Replace split() with explode()
Extension / Version: DPL   /   1.8.9
Type / Status: Bug   /   open

Problem

In PHP 5.3, the split() function is deprecated. DPL uses this function, and as a result, PHP warnings are logged. Replace all split() calls in DPL code to be explode() instead.

Diff against DPL 1.8.9

Index: DPL.php
===================================================================
--- DPL.php     (revision 15950)
+++ DPL.php     (working copy)
@@ -600,7 +600,7 @@
                $rulesText = str_replace(";",'°',$rulesText);
                $rulesText = str_replace('\°',';',$rulesText);
                $rulesText = str_replace("\\n","\n",$rulesText);
-               $rules=split('°',$rulesText);
+               $rules=explode('°',$rulesText);
                $exec='edit';
                $replaceThis='';
                $replacement='';
@@ -968,7 +968,7 @@
                                                if (($cbrackets==2 && $c=='|') || ($cbrackets==1 && $c=='}')) {
                                                        // parameter (name / value) found
 
-                                                       $token = split('=',$parm,2);
+                                                       $token = explode('=',$parm,2);
                                                        if (count($token)==2) {
                                                                // we need a pair of name / value
                                                                $parmName=trim($token[0]);
@@ -1054,7 +1054,7 @@
                $rulesText = str_replace(";",'°',$rulesText);
                $rulesText = str_replace('\°',';',$rulesText);
                $rulesText = str_replace("\\n","\n",$rulesText);
-               $rules=split('°',$rulesText);
+               $rules=explode('°',$rulesText);
                $exec=false;
                $message= '';
                $reason='';
Index: DPLSetup.php
===================================================================
--- DPLSetup.php        (revision 15950)
+++ DPLSetup.php        (working copy)
@@ -1332,7 +1332,7 @@
 
     public static function dplMatrixParserFunction(&$parser, $name, $yes, $no, $flip, $matrix ) {
         $arg_list = func_get_args();
-        $lines = split("\n",$matrix);
+        $lines = explode("\n",$matrix);
         $m = array();
         $sources = array();
         $targets = array();
Index: DPLMain.php
===================================================================
--- DPLMain.php (revision 15950)
+++ DPLMain.php (working copy)
@@ -2981,12 +2981,12 @@
         foreach ($aSecLabels as $colgroup => $label) {
             $t++;
             $groupNr++;
-            $cols = split('}:',$label);
+            $cols = explode('}:',$label);
             if (count($cols)<=1) {
                 if (array_key_exists($t,$tableRow)) $aTableRow[$groupNr]=$tableRow[$t];
             }
             else {
-                $n=count(split(':',$cols[1]));
+                $n=count(explode(':',$cols[1]));
                 $colNr=-1;
                 $t--;
                 for ($i=1;$i<=$n;$i++) {

Reply