[TYPO3-core] RFC #13649: Deprecated function sql_regcase in cms/tslib/class.tslib_pagegen.php

"Martin Müller" bugreporters at gmx.de
Fri May 7 17:36:00 CEST 2010


This is an SVN patch request.

Type: bugfix

Bugtracker references:
http://bugs.typo3.org/view.php?id=13649

Branches:  trunk

Problem:

The function pagegenInit() in typo3/sysext/cms/tslib/class.tslib_pagegen.php is using the function sql_regcase() which is deprecated in PHP 5.3.

The default front-end search form is using this function. At least if a link in the result set is clicked.


Solution:

On file class.tslib_pagegen.php function "sql_regcase()" is used for front-end search form only.
The intent is to produce a Regex with case insensitiv characters.

My proposal is to cut off additional functions for that case.
The patch 0010231 / Revision 5574 replaced split() to preg_split() on class.tslib_content.php. Now we can use the regex-modifier on regex-pattern to achieve that.

My patch cut off sql_regcase() without adding an additional function but using the regex-modifier on class.tslib_content.php to get a case sensitive/insensitive result ;-)

Notes: No

Regards Martin
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
-------------- next part --------------
Index: typo3/sysext/cms/tslib/class.tslib_content.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_content.php	(Revision 7559)
+++ typo3/sysext/cms/tslib/class.tslib_content.php	(Arbeitskopie)
@@ -4998,7 +4998,11 @@
 						if ($GLOBALS['TSFE']->no_cache && $conf['sword'] && is_array($GLOBALS['TSFE']->sWordList) && $GLOBALS['TSFE']->sWordRegEx)	{
 							$newstring = '';
 							do {
-								$pieces = preg_split('/' . $GLOBALS['TSFE']->sWordRegEx . '/', $data, 2);
+                                $pregSplitMode = 'i';
+                                if (isset($GLOBALS['TSFE']->config['config']['sword_noMixedCase']) && !empty($GLOBALS['TSFE']->config['config']['sword_noMixedCase'])) {
+                                    $pregSplitMode = '';
+                                }
+                                $pieces = preg_split('/' . $GLOBALS['TSFE']->sWordRegEx . '/'.$pregSplitMode, $data, 2);
 								$newstring.=$pieces[0];
 								$match_len = strlen($data)-(strlen($pieces[0])+strlen($pieces[1]));
 								if (strstr($pieces[0],'<') || strstr($pieces[0],'>'))	{
Index: typo3/sysext/cms/tslib/class.tslib_pagegen.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_pagegen.php	(Revision 7559)
+++ typo3/sysext/cms/tslib/class.tslib_pagegen.php	(Arbeitskopie)
@@ -163,17 +163,11 @@
 		$GLOBALS['TSFE']->sWordRegEx='';
 		$GLOBALS['TSFE']->sWordList = t3lib_div::_GP('sword_list');
 		if (is_array($GLOBALS['TSFE']->sWordList))	{
-			$standAlone = trim(''.$GLOBALS['TSFE']->config['config']['sword_standAlone']);
-			$noMixedCase = trim(''.$GLOBALS['TSFE']->config['config']['sword_noMixedCase']);
+            $space = (!empty($GLOBALS['TSFE']->config['config']['sword_standAlone'])) ? '[[:space:]]' : '';
 
-			$space = ($standAlone) ? '[[:space:]]' : '';
 			foreach ($GLOBALS['TSFE']->sWordList as $val) {
-				if (trim($val)) {
-					if (!$noMixedCase) {
-						$GLOBALS['TSFE']->sWordRegEx.= $space.sql_regcase(quotemeta($val)).$space.'|';
-					} else {
+				if (strlen(trim($val)) > 0) {
 						$GLOBALS['TSFE']->sWordRegEx.= $space.quotemeta($val).$space.'|';
-					}
 				}
 			}
 			$GLOBALS['TSFE']->sWordRegEx = preg_replace('/\|$/','',$GLOBALS['TSFE']->sWordRegEx);


More information about the TYPO3-team-core mailing list