Bug 271109

Summary: mail/roundcube: ICU & ctypes bugs
Product: Ports & Packages Reporter: Daniel O'Connor <darius>
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed Unable to Reproduce    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (ale)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Daniel O'Connor 2023-04-28 00:49:59 UTC
Hi,
I just installed the roundcube-php81-1.6.1,1 package on a 13.1-RELEASE-p6 system and ran into two problems.

The first was:
[28-Apr-2023 00:30:52 +0000]: <mksj46p8> DB Error: SQLSTATE[HY000] [14] unable to open database file in /usr/local/www/roundcube/program/lib/Roundcube/rcube_db.php on line 201 (GET /)
[28-Apr-2023 00:31:31 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "INTL_IDNA_VARIANT_UTS46" in /usr/local/www/roundcube/program/lib/Roundcube/rcube_utils.php:1153

Which I fixed by replacing INTL_IDNA_VARIANT_UTS46 with 0 as per https://github.com/guzzle/guzzle/pull/2454/commits/c63379edaad8af790be9e3bbd3d40d4eaae4e30c

The second was:
[28-Apr-2023 00:38:29 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function Masterminds\HTML5\Parser\ctype_alpha() in /usr/local/www/roundcube/vendor/masterminds/html5/src/HTM
L5/Parser/Tokenizer.php:140

Which I fixed by replacing the ctype_alpha() call with a hand rolled function as per https://github.com/Masterminds/html5-php/issues/173
Comment 1 Alex Dupre freebsd_committer freebsd_triage 2023-04-28 06:12:54 UTC
It looks like you have something wrong in your installation, because:
1) the ICU version shipped with FreeBSD has the INTL_IDNA_VARIANT_UTS46 constant
2) the PHP ctype extension is a dependency of roundcube
Comment 2 Daniel O'Connor 2023-04-28 06:15:40 UTC
Yes I was surprised also, but I have php81-ctype-8.1.17 and icu-72.1,1 installed..
Comment 3 Alex Dupre freebsd_committer freebsd_triage 2023-04-28 06:25:55 UTC
Try debugging your installation with php -i / phpinfo(), as you can see everything should work properly:

pkg list
roundcube-php81-1.6.1,1        Fully skinnable XHTML/CSS webmail written in PHP
php81-intl-8.1.16_1            The intl shared extension for php
php81-ctype-8.1.16_1           The ctype shared extension for php
icu-72.1,1                     International Components for Unicode (from IBM)


% cat test.php
<?
$domain = 'FreeBSD.org';
$variant = INTL_IDNA_VARIANT_UTS46;

$options = IDNA_NONTRANSITIONAL_TO_ASCII;
var_dump(idn_to_ascii($domain, $options, $variant));
$options = IDNA_NONTRANSITIONAL_TO_UNICODE;
var_dump(idn_to_utf8($domain, $options, $variant));

var_dump(ctype_alpha('FreeBSD'));
var_dump(ctype_alpha('FreeBSD 13.1'));
?>

% php test.php
string(11) "freebsd.org"
string(11) "freebsd.org"
bool(true)
bool(false)
Comment 4 Daniel O'Connor 2023-04-28 06:43:40 UTC
Hmm that works fine (I had to make the first line '<?php' though) - I get the same result as you.

I am running PHP scripts via php-fpm (web server is nginx).
If I run the script via the web server I get the same error as I saw in roundcube.
Comment 5 Daniel O'Connor 2023-04-28 06:50:35 UTC
Ahh damnit I just realised what happened.
I forgot to restart php-fpm after the new PHP packages were installed.

I restarted it and now it works!

Sorry for the noise.