aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2013-11-20 14:04:06 +0100
committerNicolas Grekas <nicolas.grekas@gmail.com>2014-11-08 11:41:55 +0100
commita2300eb3aa428a080314caf0c0b60556f6701ffa (patch)
tree1d1ef4830e8f60891143ef629684160848d85f19
parent5a7caf65084369422fdbe4aaaae46e5de69cc594 (diff)
downloadforums-a2300eb3aa428a080314caf0c0b60556f6701ffa.tar
forums-a2300eb3aa428a080314caf0c0b60556f6701ffa.tar.gz
forums-a2300eb3aa428a080314caf0c0b60556f6701ffa.tar.bz2
forums-a2300eb3aa428a080314caf0c0b60556f6701ffa.tar.xz
forums-a2300eb3aa428a080314caf0c0b60556f6701ffa.zip
[feature/patchwork-utf8] Remove utf8_str_replace
-rw-r--r--phpBB/includes/utf/utf_tools.php47
-rw-r--r--phpBB/phpbb/db/driver/driver.php8
2 files changed, 4 insertions, 51 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index 19963287e5..2fbc1ce520 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1902,50 +1902,3 @@ function utf8_basename($filename)
return $filename;
}
-
-/**
-* UTF8-safe str_replace() function
-*
-* @param string $search The value to search for
-* @param string $replace The replacement string
-* @param string $subject The target string
-* @return string The resultant string
-*/
-function utf8_str_replace($search, $replace, $subject)
-{
- if (!is_array($search))
- {
- $search = array($search);
- if (is_array($replace))
- {
- $replace = (string) $replace;
- trigger_error('Array to string conversion', E_USER_NOTICE);
- }
- }
-
- $length = sizeof($search);
-
- if (!is_array($replace))
- {
- $replace = array_fill(0, $length, $replace);
- }
- else
- {
- $replace = array_pad($replace, $length, '');
- }
-
- for ($i = 0; $i < $length; $i++)
- {
- $search_length = utf8_strlen($search[$i]);
- $replace_length = utf8_strlen($replace[$i]);
-
- $offset = 0;
- while (($start = utf8_strpos($subject, $search[$i], $offset)) !== false)
- {
- $subject = utf8_substr($subject, 0, $start) . $replace[$i] . utf8_substr($subject, $start + $search_length);
- $offset = $start + $replace_length;
- }
- }
-
- return $subject;
-}
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php
index 4be315a154..8d360fc3e2 100644
--- a/phpBB/phpbb/db/driver/driver.php
+++ b/phpBB/phpbb/db/driver/driver.php
@@ -363,8 +363,8 @@ abstract class driver implements driver_interface
*/
function sql_like_expression($expression)
{
- $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression);
- $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
+ $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression);
+ $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\'');
}
@@ -374,8 +374,8 @@ abstract class driver implements driver_interface
*/
function sql_not_like_expression($expression)
{
- $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression);
- $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
+ $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression);
+ $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
return $this->_sql_not_like_expression('NOT LIKE \'' . $this->sql_escape($expression) . '\'');
}