diff --git a/composer.json b/composer.json index edb9138d79..5e2bb13b13 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,6 @@ ], "require": { "php": ">=5.5.0", - "ext-mbstring": "*", "ext-mysqli": "*", "ext-xml": "*", "ext-pcre": "*", @@ -46,7 +45,8 @@ "psr/container": "^1.0", "twig/twig": "^1.32", "twig/extensions": "~1.4.1", - "symfony/expression-language": "^3.2" + "symfony/expression-language": "^3.2", + "symfony/polyfill-mbstring": "^1.3" }, "conflict": { "tecnickcom/tcpdf": "<6.2" @@ -59,6 +59,7 @@ "ext-bz2": "For bzip2 import and export", "ext-zip": "For zip import and export", "ext-gd2": "For image transformations", + "ext-mbstring": "For best performance", "tecnickcom/tcpdf": "For PDF support" }, "require-dev": { diff --git a/doc/require.rst b/doc/require.rst index a6e84ebc39..0de03a5728 100644 --- a/doc/require.rst +++ b/doc/require.rst @@ -13,7 +13,10 @@ PHP --- * You need PHP 5.5.0 or newer, with ``session`` support, the Standard PHP Library - (SPL) extension, JSON support, and the ``mbstring`` extension (see :term:`mbstring`). + (SPL) extension, and JSON support. + +* The ``mbstring`` extension (see :term:`mbstring`) is strongly recommended + for performance reasons. * To support uploading of ZIP files, you need the PHP ``zip`` extension. diff --git a/libraries/Encoding.php b/libraries/Encoding.php index 1f58bb61b3..209d94f406 100644 --- a/libraries/Encoding.php +++ b/libraries/Encoding.php @@ -195,10 +195,7 @@ class Encoding */ public static function canConvertKanji() { - return ( - $GLOBALS['lang'] == 'ja' && - function_exists('mb_convert_encoding') - ); + return $GLOBALS['lang'] == 'ja'; } /** diff --git a/libraries/config/FormDisplay.php b/libraries/config/FormDisplay.php index 86b71e7415..1dbd458756 100644 --- a/libraries/config/FormDisplay.php +++ b/libraries/config/FormDisplay.php @@ -818,13 +818,7 @@ class FormDisplay 'recode', 'recode' ); } - if (!function_exists('mb_convert_encoding')) { - $opts['values']['mb'] .= ' (' . __('unavailable') . ')'; - $comment .= ($comment ? ", " : '') . sprintf( - __('"%s" requires %s extension'), - 'mb', 'mbstring' - ); - } + /* mbstring is always there thanks to polyfill */ $opts['comment'] = $comment; $opts['comment_warning'] = true; } diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 436ae46a60..5fea4b4d5f 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -17,11 +17,6 @@ if (! defined('PHPMYADMIN')) { exit; } -/** - * String handling (security) - */ -require_once 'libraries/string.lib.php'; - /** * checks given $var and returns it if valid, or $default of not valid * given $var is also checked for type being 'similar' as $default @@ -235,15 +230,7 @@ function PMA_fatalError($error_message, $message_args = null) { $response->addJSON('message', PMA\libraries\Message::error($error_message)); } else { $error_message = strtr($error_message, array('
' => '[br]')); - - // these variables are used in the included file libraries/error.inc.php - //first check if php-mbstring is available - if (function_exists('mb_detect_encoding')) { - //If present use gettext - $error_header = __('Error'); - } else { - $error_header = 'Error'; - } + $error_header = __('Error'); $lang = isset($GLOBALS['lang']) ? $GLOBALS['lang'] : 'en'; $dir = isset($GLOBALS['text_dir']) ? $GLOBALS['text_dir'] : 'ltr'; @@ -916,7 +903,7 @@ function PMA_checkExtensions() * Warning about mbstring. */ if (! function_exists('mb_detect_encoding')) { - PMA_warnMissingExtension('mbstring', true); + PMA_warnMissingExtension('mbstring'); } /** diff --git a/libraries/string.lib.php b/libraries/string.lib.php deleted file mode 100644 index e1e54f37d3..0000000000 --- a/libraries/string.lib.php +++ /dev/null @@ -1,33 +0,0 @@ -= strlen($haystack) - ) { - return false; - } - return stripos($haystack, $needle, $offset); - } - - /** - * Returns position of last $needle in $haystack or false if not found - * - * @param string $haystack the string being checked - * @param string $needle the string to find in haystack - * @param int $offset the search offset - * - * @return integer position of last $needle in $haystack or false - */ - function mb_strrpos($haystack, $needle, $offset = 0) - { - return strrpos($haystack, $needle, $offset); - } - - /** - * Returns position of last $needle in $haystack - case insensitive - or false - * if not found - * - * @param string $haystack the string being checked - * @param string $needle the string to find in haystack - * @param int $offset the search offset - * - * @return integer position of last $needle in $haystack or false - */ - function mb_strripos($haystack, $needle, $offset = 0) - { - if (('' === $haystack || false === $haystack) && $offset >= strlen($haystack) - ) { - return false; - } - return strripos($haystack, $needle, $offset); - } - - /** - * Returns part of $haystack string starting from and including the first - * occurrence of $needle to the end of $haystack or false if not found - * - * @param string $haystack the string being checked - * @param string $needle the string to find in haystack - * @param bool $before_needle the part before the needle - * - * @return string part of $haystack or false - */ - function mb_strstr($haystack, $needle, $before_needle = false) - { - return strstr($haystack, $needle, $before_needle); - } - - /** - * Returns part of $haystack string starting from and including the first - * occurrence of $needle to the end of $haystack - case insensitive - or false - * if not found - * - * @param string $haystack the string being checked - * @param string $needle the string to find in haystack - * @param bool $before_needle the part before the needle - * - * @return string part of $haystack or false - */ - function mb_stristr($haystack, $needle, $before_needle = false) - { - return stristr($haystack, $needle, $before_needle); - } - - /** - * Returns the portion of haystack which starts at the last occurrence or false - * if not found - * - * @param string $haystack the string being checked - * @param string $needle the string to find in haystack - * - * @return string portion of haystack which starts at the last occurrence or - * false - */ - function mb_strrchr($haystack, $needle) - { - return strrchr($haystack, $needle); - } - - /** - * Make a string lowercase - * - * @param string $string the string being lowercased - * - * @return string the lower case string - */ - function mb_strtolower($string) - { - return strtolower($string); - } - - /** - * Make a string uppercase - * - * @param string $string the string being uppercased - * - * @return string the upper case string - */ - function mb_strtoupper($string) - { - return strtoupper($string); - } -} - -//New functions. -if (!@function_exists('mb_ord')) { - /** - * Perform a regular expression match - * - * @param string $pattern Pattern to search for - * @param string $subject Input string - * @param int $offset Start from search - * - * @return int 1 if matched, 0 if doesn't, false on failure - */ - function mb_preg_strpos($pattern, $subject, $offset = 0) - { - $matches = array(); - $bFind = preg_match( - $pattern, $subject, $matches, PREG_OFFSET_CAPTURE, $offset - ); - if (1 !== $bFind) { - return false; - } - - return $matches[1][1]; - } - - /** - * Get the ordinal value of a string - * - * @param string $string the string for which ord is required - * - * @return int the ord value - */ - function mb_ord($string) - { - return ord($string); - } - - /** - * Get the character of an ASCII - * - * @param int $ascii the ASCII code for which character is required - * - * @return string the character - */ - function mb_chr($ascii) - { - return chr($ascii); - } -} \ No newline at end of file diff --git a/test/classes/DisplayResultsTest.php b/test/classes/DisplayResultsTest.php index 63387cf3a8..e561734f7a 100644 --- a/test/classes/DisplayResultsTest.php +++ b/test/classes/DisplayResultsTest.php @@ -11,7 +11,6 @@ use PMA\libraries\plugins\transformations\Text_Plain_Link; require_once 'libraries/relation.lib.php'; -require_once 'libraries/string.lib.php'; require_once 'test/PMATestCase.php'; /** diff --git a/test/classes/EncodingTest.php b/test/classes/EncodingTest.php index 01a5c54f8d..d1d145c566 100644 --- a/test/classes/EncodingTest.php +++ b/test/classes/EncodingTest.php @@ -84,10 +84,6 @@ class EncodingTest extends PHPUnit_Framework_TestCase public function testMbstring() { - if (! @function_exists('mb_convert_encoding')) { - $this->markTestSkipped('mbstring extension missing'); - } - Encoding::setEngine(Encoding::ENGINE_MB); $this->assertEquals( "This is the Euro symbol '?'.", diff --git a/test/classes/config/FormDisplayTest.php b/test/classes/config/FormDisplayTest.php index 9fe2940a50..96a703e421 100644 --- a/test/classes/config/FormDisplayTest.php +++ b/test/classes/config/FormDisplayTest.php @@ -411,6 +411,7 @@ class FormDisplayTest extends PMATestCase $opts = array('values' => array()); $opts['values']['iconv'] = 'testIconv'; $opts['values']['recode'] = 'testRecode'; + $opts['values']['mb'] = 'testMB'; $expect = $opts;