Fixed bug #10231: split() is deprecated in PHP 5.3 (patch by Karsten Dambekalns)
authorMichael Stucki <michael.stucki@typo3.org>
Fri, 23 Jan 2009 15:11:14 +0000 (15:11 +0000)
committerMichael Stucki <michael.stucki@typo3.org>
Fri, 23 Jan 2009 15:11:14 +0000 (15:11 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4827 709f56b5-9817-0410-a4d7-c38de5d9e867

13 files changed:
ChangeLog
t3lib/class.t3lib_cs.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_htmlmail.php
t3lib/class.t3lib_matchcondition.php
t3lib/class.t3lib_tceforms.php
typo3/mod/tools/em/class.em_index.php
typo3/mod/tools/em/class.nusoap.php
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/install/mod/class.tx_install.php
typo3/view_help.php

index fd2c63c..95878b8 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-23  Michael Stucki  <michael@typo3.org>
+
+       * Fixed bug #10231: split() is deprecated in PHP 5.3 (patch by Karsten Dambekalns)
+
 2009-01-22  Steffen Kamper  <info@sk-typo3.de>
 
        * Fixed bug #9345: Bug: CSV export includes _CLIPBOARD_ in header row (thanks to Christian Kuhn)
index ca78121..3060ea6 100755 (executable)
@@ -990,7 +990,7 @@ class t3lib_cs {
                                                        if (!$detectedType)             $detectedType = ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value) ? 'whitespaced' : 'ms-token';
 
                                                        if ($detectedType=='ms-token')  {
-                                                               list($hexbyte,$utf8) = split('=|:',$value,3);
+                                                               list($hexbyte, $utf8) = preg_split('/[=:]/', $value, 3);
                                                        } elseif ($detectedType=='whitespaced') {
                                                                $regA=array();
                                                                ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value,$regA);
@@ -1074,7 +1074,7 @@ class t3lib_cs {
                while (!feof($fh))      {
                        $line = fgets($fh,4096);
                                // has a lot of info
-                       list($char,$name,$cat,,,$decomp,,,$num,,,,$upper,$lower,$title,) = split(';', rtrim($line));
+                       list($char,$name,$cat,,,$decomp,,,$num,,,,$upper,$lower,$title,) = explode(';', rtrim($line));
 
                        $ord = hexdec($char);
                        if ($ord > 0xFFFF)      break;  // only process the BMP
@@ -1128,7 +1128,7 @@ class t3lib_cs {
                                        case '<vertical>':
                                                continue 2;
                                }
-                               $decomposition["U+$char"] = split(' ',$match[2]);
+                               $decomposition["U+$char"] = explode(' ', $match[2]);
                        }
                }
                fclose($fh);
@@ -1146,17 +1146,17 @@ class t3lib_cs {
                                                if ($cond == '' || $cond{0} == '#')     {
                                                        $utf8_char = $this->UnumberToChar(hexdec($char));
                                                        if ($char != $lower)    {
-                                                               $arr = split(' ',$lower);
+                                                               $arr = explode(' ', $lower);
                                                                for ($i=0; isset($arr[$i]); $i++)       $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
                                                                $utf8CaseFolding['toLower'][$utf8_char] = implode('',$arr);
                                                        }
                                                        if ($char != $title && $title != $upper)        {
-                                                               $arr = split(' ',$title);
+                                                               $arr = explode(' ', $title);
                                                                for ($i=0; isset($arr[$i]); $i++)       $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
                                                                $utf8CaseFolding['toTitle'][$utf8_char] = implode('',$arr);
                                                        }
                                                        if ($char != $upper)    {
-                                                                       $arr = split(' ',$upper);
+                                                                       $arr = explode(' ', $upper);
                                                                for ($i=0; isset($arr[$i]); $i++)       $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
                                                                $utf8CaseFolding['toUpper'][$utf8_char] = implode('',$arr);
                                                        }
@@ -1177,7 +1177,7 @@ class t3lib_cs {
                                        if ($line{0} != '#' && trim($line) != '')       {
                                                list($char,$translit) = t3lib_div::trimExplode(';', $line);
                                                if (!$translit) $omit["U+$char"] = 1;
-                                               $decomposition["U+$char"] = split(' ', $translit);
+                                               $decomposition["U+$char"] = explode(' ', $translit);
 
                                        }
                                }
index 3d34759..218cae2 100755 (executable)
@@ -1725,7 +1725,7 @@ final class t3lib_div {
                        }
                                // create_function() returns a string:
                        if (!is_string($getValueFunc)) {
-                               $getValueFunc = null; 
+                               $getValueFunc = null;
                        }
                                // Do the filtering:
                        if (is_array($keepItems) && count($keepItems)) {
@@ -2052,7 +2052,7 @@ final class t3lib_div {
                                $tag_tmp = trim(substr($tag_tmp,1));            // Removes = chars.
                        } else {
                                        // There are '' around the value. We look for the next ' ' or '>'
-                               $reg = split('[[:space:]=]',$tag_tmp,2);
+                               $reg = preg_split('/[[:space:]=]/', $tag_tmp, 2);
                                $value[] = trim($reg[0]);
                                $tag_tmp = trim(substr($tag_tmp,strlen($reg[0]),1).$reg[1]);
                        }
index 4c2754a..8011c8a 100755 (executable)
@@ -923,7 +923,7 @@ class t3lib_htmlmail {
                $attribRegex = $this->tag_regex(array('img','table','td','tr','body','iframe','script','input','embed'));
 
                        // split the document by the beginning of the above tags
-               $codepieces = split($attribRegex, $html_code);
+               $codepieces = preg_split($attribRegex, $html_code);
                $len = strlen($codepieces[0]);
                $pieces = count($codepieces);
                $reg = array();
@@ -954,7 +954,7 @@ class t3lib_htmlmail {
                        // Extracting stylesheets
                $attribRegex = $this->tag_regex(array('link'));
                        // Split the document by the beginning of the above tags
-               $codepieces = split($attribRegex, $html_code);
+               $codepieces = preg_split($attribRegex, $html_code);
                $pieces = count($codepieces);
                for ($i = 1; $i < $pieces; $i++) {
                        $dummy = eregi("[^>]*", $codepieces[$i], $reg);
@@ -977,7 +977,7 @@ class t3lib_htmlmail {
                }
 
                        // fixes javascript rollovers
-               $codepieces = split(quotemeta(".src"), $html_code);
+               $codepieces = preg_split('/' . quotemeta(".src") . '/', $html_code);
                $pieces = count($codepieces);
                $expr = "^[^".quotemeta("\"").quotemeta("'")."]*";
                for($i = 1; $i < $pieces; $i++) {
@@ -1013,7 +1013,7 @@ class t3lib_htmlmail {
        public function extractHyperLinks() {
                $html_code = $this->theParts['html']['content'];
                $attribRegex = $this->tag_regex(array('a','form','area'));
-               $codepieces = split($attribRegex, $html_code);  // Splits the document by the beginning of the above tags
+               $codepieces = preg_split($attribRegex, $html_code);     // Splits the document by the beginning of the above tags
                $len = strlen($codepieces[0]);
                $pieces = count($codepieces);
                for($i = 1; $i < $pieces; $i++) {
@@ -1069,7 +1069,7 @@ class t3lib_htmlmail {
                if (strpos(' '.$htmlCode,'<frame ')) {
                        $attribRegex = $this->tag_regex('frame');
                                // Splits the document by the beginning of the above tags
-                       $codepieces = split($attribRegex, $htmlCode, 1000000);
+                       $codepieces = preg_split($attribRegex, $htmlCode, 1000000);
                        $pieces = count($codepieces);
                        for($i = 1; $i < $pieces; $i++) {
                                $dummy = eregi("[^>]*", $codepieces[$i], $reg);
@@ -1418,13 +1418,13 @@ class t3lib_htmlmail {
         */
        public function tag_regex($tags) {
                $tags = (!is_array($tags) ? array($tags) : $tags);
-               $regexp = '';
+               $regexp = '/';
                $c = count($tags);
                foreach($tags as $tag) {
                        $c--;
                        $regexp .= '<' . sql_regcase($tag) . "[[:space:]]" . (($c) ? '|' : '');
                }
-               return $regexp;
+               return $regexp . '/';
        }
 
 
@@ -1444,7 +1444,7 @@ class t3lib_htmlmail {
                        // Find attribute
                while ($tag) {
                        $value = '';
-                       $reg = split("[[:space:]=>]",$tag,2);
+                       $reg = preg_split('/[[:space:]=>]/', $tag, 2);
                        $attrib = $reg[0];
 
                        $tag = ltrim(substr($tag,strlen($attrib),$tagLen));
index 10ba954..23f3191 100644 (file)
@@ -237,7 +237,7 @@ class t3lib_matchCondition {
                                        $test = trim($test);
                                        if (strlen($test)) {
                                                if (preg_match('/^\*.+\*$/',$test))     {
-                                                       $allLanguages = split('[,;]',t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
+                                                       $allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
                                                        if (in_array(substr($test,1,-1), $allLanguages))        {return true;}
                                                } else {
                                                        if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test)     {return true;}
@@ -359,7 +359,7 @@ class t3lib_matchCondition {
                                { return t3lib_div::compat_version($value); }
                        break;
                        case 'userFunc':
-                               $values = split('\(|\)',$value);
+                               $values = preg_split('/[\(\)]/', $value);
                                $funcName=trim($values[0]);
                                $funcValue = t3lib_div::trimExplode(',',$values[1]);
                                $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
index 9f61096..d8bfce9 100755 (executable)
@@ -720,7 +720,7 @@ class t3lib_TCEforms        {
 
                $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
                foreach($editFieldList as $theFieldC)   {
-                       list($theField,$palFields) = split('\[|\]',$theFieldC);
+                       list($theField,$palFields) = preg_split('/\[|\]/', $theFieldC);
                        $theField = trim($theField);
                        $palFields = trim($palFields);
                        if ($TCA[$table]['columns'][$theField]) {
@@ -2612,7 +2612,7 @@ class t3lib_TCEforms      {
                                                                // Kasper's comment (kept for history): Maybe there is a better way to do this than store the HTML for the new element in rawurlencoded format - maybe it even breaks with certain charsets? But for now this works...
                                                                $this->additionalJS_post = $additionalJS_post_saved;
                                                                $this->additionalJS_submit = $additionalJS_submit_saved;
-                                                               $new = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.new', 1); 
+                                                               $new = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.new', 1);
                                                                $newElementsLinks[]= '<a href="#" onclick="'.htmlspecialchars($onClickInsert).'">
                                                                        <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="' . $new . '" title="' . $new . '" align="absmiddle" />' .
                                                                        htmlspecialchars(t3lib_div::fixed_lgd_cs($this->sL($nCfg['tx_templavoila']['title']),30)) . '</a>';
@@ -2626,7 +2626,7 @@ class t3lib_TCEforms      {
                                                        $output.= '
                                                        <div style="padding: 5px 0px 5px 20px;">
                                                        <a href="#" onclick="'.htmlspecialchars('flexFormToggleSubs("'.$idTagPrefix.'"); return false;').'">
-                                                               <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2right.gif','width="7" height="12"').' align="absmiddle" alt="' . 
+                                                               <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/pil2right.gif', 'width="7" height="12"') . ' align="absmiddle" alt="' .
                                                                $toggleAll . '" title="' . $toggleAll . '" />
                                                                <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2right.gif','width="7" height="12"').' align="absmiddle" alt="' .
                                                                $toggleAll . '" title="' . $toggleAll . '" />' . $toggleAll . '
index d33cb8c..19a43a7 100644 (file)
@@ -3570,7 +3570,7 @@ EXTENSION KEYS:
                                                                }
                                                        }
                                                        //
-                                                       $XclassParts = split('if \(defined\([\'"]TYPO3_MODE[\'"]\) && \$TYPO3_CONF_VARS\[TYPO3_MODE\]\[[\'"]XCLASS[\'"]\]',$fContent,2);
+                                                       $XclassParts = preg_split('/if \(defined\([\'"]TYPO3_MODE[\'"]\) && \$TYPO3_CONF_VARS\[TYPO3_MODE\]\[[\'"]XCLASS[\'"]\]/', $fContent, 2);
                                                        if (count($XclassParts)==2)     {
                                                                unset($reg);
                                                                preg_match('/^\[[\'"]([[:alnum:]_\/\.]*)[\'"]\]/',$XclassParts[1],$reg);
index 2701a61..cabfab1 100644 (file)
@@ -2907,7 +2907,7 @@ class soap_transport_http extends nusoap_base {
         */
        function parseCookie($cookie_str) {
                $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
-               $data = split(';', $cookie_str);
+               $data = explode(';', $cookie_str);
                $value_str = $data[0];
 
                $cookie_param = 'domain=';
index 313c36c..54da6c0 100755 (executable)
@@ -2270,7 +2270,7 @@ class tx_cms_layout extends recordList {
         * @return      string          Processed output.
         */
        function wordWrapper($content,$max=50,$char=' -')       {
-               $array = split(' |'.chr(10),$content);
+               $array = preg_split('/[ ' . chr(10) . ']/', $content);
                foreach($array as $val) {
                        if (strlen($val)>$max)  {
                                $content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content);
index b06379a..c9f509f 100755 (executable)
@@ -3129,10 +3129,10 @@ class tslib_cObj {
                                while(list($tK,$tV)=each($aKeys))       {
                                        $aKeys[$tK]=quotemeta($tV);
                                }
-                               $regex = implode('|',$aKeys);
+                               $regex = '/' . implode('|', $aKeys) . '/';
                                        // Doing regex's
-                               $storeArr['c'] = split($regex,$content);
-                               preg_match_all('/'.$regex.'/',$content,$keyList);
+                               $storeArr['c'] = preg_split($regex, $content);
+                               preg_match_all($regex, $content, $keyList);
                                $storeArr['k']=$keyList[0];
                                        // Setting cache:
                                $this->substMarkerCache[$storeKey] = $storeArr;
@@ -4436,7 +4436,7 @@ class tslib_cObj {
                                                if ($GLOBALS['TSFE']->no_cache && $conf['sword'] && is_array($GLOBALS['TSFE']->sWordList) && $GLOBALS['TSFE']->sWordRegEx)      {
                                                        $newstring = '';
                                                        do {
-                                                               $pieces = split($GLOBALS['TSFE']->sWordRegEx,$data,2);
+                                                               $pieces = preg_split('/' . $GLOBALS['TSFE']->sWordRegEx . '/', $data, 2);
                                                                $newstring.=$pieces[0];
                                                                $match_len = strlen($data)-(strlen($pieces[0])+strlen($pieces[1]));
                                                                if (strstr($pieces[0],'<') || strstr($pieces[0],'>'))   {
@@ -6054,7 +6054,7 @@ class tslib_cObj {
         * @return      string          Cleaned up string, keywords will be separated by a comma only.
         */
        function keywords($content)     {
-               $listArr = split(',|;|'.chr(10),$content);
+               $listArr = preg_split('/[,;' . chr(10) . ']/', $content);
                reset($listArr);
                while(list($k,$v)=each($listArr))       {
                        $listArr[$k]=trim($v);
@@ -6177,7 +6177,7 @@ class tslib_cObj {
 
                $emailContent = trim($msg);
                if ($emailContent)      {
-                       $parts = split(chr(10),$emailContent,2);                // First line is subject
+                       $parts = explode(chr(10), $emailContent, 2);            // First line is subject
                        $subject=trim($parts[0]);
                        $plain_message=trim($parts[1]);
 
@@ -6965,7 +6965,7 @@ class tslib_cObj {
                $where = '';
                if ($sw)        {
                        $searchFields = explode(',',$searchFieldList);
-                       $kw = split('[ ,]',$sw);
+                       $kw = preg_split('/[ ,]/', $sw);
 
                        while(list(,$val)=each($kw))    {
                                $val = trim($val);
index 505e989..f8da015 100755 (executable)
@@ -1547,7 +1547,7 @@ require_once (PATH_t3lib.'class.t3lib_lock.php');
                        $res = t3lib_div::getURL($code, 1, $headerArr);
 
                                // Header and content are separated by an empty line
-                       list($header,$content) = split("\r\n\r\n", $res, 2);
+                       list($header, $content) = preg_split("/[\r\n\r\n]/", $res, 2);
                        $content.= "\r\n";
 
                        if (false === $res) {
index 5fa613b..cedf77d 100755 (executable)
@@ -4512,7 +4512,7 @@ From sub-directory:
         * @return      [type]          ...
         */
        function suggestTCAFieldDefinition($fieldName,$fieldInfo)       {
-               list($type,$len) = split(' |\(|\)',$fieldInfo,3);
+               list($type,$len) = preg_split('/ |\(|\)/', $fieldInfo, 3);
                switch($type)   {
                        case 'int':
 $out="
index 7f366ea..9b1e402 100755 (executable)
@@ -534,7 +534,7 @@ class SC_view_help {
                global $TCA,$BE_USER,$TCA_DESCR;
 
                        // Split references by comma, vert.line or linebreak
-               $items = split(',|'.chr(10),$value);
+               $items = preg_split('/[,|' . chr(10) . ']/', $value);
                $lines = array();
 
                foreach($items as $val) {