]> git.mxchange.org Git - friendica.git/commitdiff
Added check for IntlChar module
authorMichael <heluecht@pirati.ca>
Wed, 11 Oct 2023 19:20:51 +0000 (19:20 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 11 Oct 2023 19:20:51 +0000 (19:20 +0000)
doc/Install.md
src/Core/Installer.php
src/Model/Item.php

index bf9dffb3574fd182e95cccb64663a0423a65014e..dc390fbc8ab243d61b7040400363c2f171c6b5b8 100644 (file)
@@ -28,9 +28,9 @@ Due to the large variety of operating systems and PHP platforms in existence we
 ### Requirements
 
 * Apache with mod-rewrite enabled and "Options All" so you can use a local `.htaccess` file
-* PHP 7.3+ (PHP8 is not fully supported yet)
+* PHP 7.3+
   * PHP *command line* access with register_argc_argv set to true in the php.ini file
-  * Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip and OpenSSL extensions
+  * Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip, IntlChar and OpenSSL extensions
   * The POSIX module of PHP needs to be activated (e.g. [RHEL, CentOS](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) have disabled it)
   * Some form of email server or email gateway such that PHP mail() works.
     If you cannot set up your own email server, you can use the [phpmailer](https://github.com/friendica/friendica-addons/tree/develop/phpmailer) addon and use a remote SMTP server.
index 583ad5fe28e7f5e04f3cf9d177d456b95fd90526..68f40c01a1694cfca3c3ea99b5d9a9bde1d66d4c 100644 (file)
@@ -384,12 +384,10 @@ class Installer
 
                $help = '';
                $status = true;
-               if (function_exists('apache_get_modules')) {
-                       if (!in_array('mod_rewrite', apache_get_modules())) {
-                               $help = DI::l10n()->t('Error: Apache webserver mod-rewrite module is required but not installed.');
-                               $status = false;
-                               $returnVal = false;
-                       }
+               if (function_exists('apache_get_modules') && !in_array('mod_rewrite', apache_get_modules())) {
+                       $help = DI::l10n()->t('Error: Apache webserver mod-rewrite module is required but not installed.');
+                       $status = false;
+                       $returnVal = false;
                }
                $this->addCheck(DI::l10n()->t('Apache mod_rewrite module'), $status, true, $help);
 
@@ -399,15 +397,22 @@ class Installer
                        $status = false;
                        $help = DI::l10n()->t('Error: PDO or MySQLi PHP module required but not installed.');
                        $returnVal = false;
-               } else {
-                       if (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', \PDO::getAvailableDrivers())) {
-                               $status = false;
-                               $help = DI::l10n()->t('Error: The MySQL driver for PDO is not installed.');
-                               $returnVal = false;
-                       }
+               } elseif (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', \PDO::getAvailableDrivers())) {
+                       $status = false;
+                       $help = DI::l10n()->t('Error: The MySQL driver for PDO is not installed.');
+                       $returnVal = false;
                }
                $this->addCheck(DI::l10n()->t('PDO or MySQLi PHP module'), $status, true, $help);
 
+               $help   = '';
+               $status = true;
+               if (!class_exists('IntlChar')) {
+                       $status    = false;
+                       $help      = DI::l10n()->t('Error: The IntlChar module is not installed.');
+                       $returnVal = false;
+               }
+               $this->addCheck(DI::l10n()->t('IntlChar PHP module'), $status, true, $help);
+
                // check for XML DOM Documents being able to be generated
                $help = '';
                $status = true;
index 55884a802eeef1099c096434a9dff21f17ae74d0..ad93b949d9f6e01600108be8c2160b919cce3561 100644 (file)
@@ -49,7 +49,6 @@ use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 use GuzzleHttp\Psr7\Uri;
-use IntlChar;
 use LanguageDetection\Language;
 
 class Item
@@ -2064,6 +2063,10 @@ class Item
         */
        private static function splitByBlocks(string $body): array
        {
+               if (class_exists('IntlChar')) {
+                       return [$body];
+               }
+
                $blocks         = [];
                $previous_block = 0;
 
@@ -2072,12 +2075,12 @@ class Item
                        $previous  = ($i > 0) ? mb_substr($body, $i - 1, 1) : '';
                        $next      = ($i < mb_strlen($body)) ? mb_substr($body, $i + 1, 1) : '';
 
-                       if (!IntlChar::isalpha($character)) {
-                               if (($previous != '') && (IntlChar::isalpha($previous))) {
+                       if (!\IntlChar::isalpha($character)) {
+                               if (($previous != '') && (\IntlChar::isalpha($previous))) {
                                        $previous_block = self::getBlockCode($previous);
                                }
 
-                               $block = (($next != '') && IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
+                               $block = (($next != '') && \IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
                                $blocks[$block] = ($blocks[$block] ?? '') . $character;
                        } else {
                                $block = self::getBlockCode($character);
@@ -2103,7 +2106,7 @@ class Item
         */
        private static function getBlockCode(string $character): int
        {
-               if (!IntlChar::isalpha($character)) {
+               if (!\IntlChar::isalpha($character)) {
                        return 0;
                }
                return self::isLatin($character) ? 1 : 2;
@@ -2117,11 +2120,11 @@ class Item
         */
        private static function isLatin(string $character): bool
        {
-               return in_array(IntlChar::getBlockCode($character), [
-                       IntlChar::BLOCK_CODE_BASIC_LATIN, IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
+               return in_array(\IntlChar::getBlockCode($character), [
+                       \IntlChar::BLOCK_CODE_BASIC_LATIN, \IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
                ]);
        }