# php56->7.2 roundcube issues with filter_var()



## mwilbur (Nov 2, 2019)

Hello,
I recently upgraded an 11.2-R host to 12.0-R from sources without issue -- until I was dumb enough to do a mass upgrade via pkg 
I ended up getting postfix, dovecot, mysql working with their upgraded versions (and lots of builds from src), but roundcube is causing me headaches. I'm unable to access it, seeing this error via apache:

```
[Fri Nov 01 18:31:34.112854 2019] [php7:error] [pid 26949] [client x.x.y.180:53929] PHP Fatal error:  Uncaught Error: Call to undefined function filter_var() in /usr/local/www/roundcube/program/lib/Roundcube/bootstrap.php:43\nStack trace:\n#0 /usr/local/www/roundcube/program/include/iniset.php(63): require_once()\n#1 /usr/local/www/roundcube/index.php(40): require_once('/usr/local/www/...')\n#2 {main}\n  thrown in /usr/local/www/roundcube/program/lib/Roundcube/bootstrap.php on line 43
```
line 43 of boostrap.php looks like: 

```
$ini_optval = filter_var(ini_get($optname), is_bool($optval) ? FILTER_VALIDATE_BOOLEAN FILTER_VALIDATE_INT);
```
I don't think it's an issue with filter_var() itself, as a little test code tells me filter_var() is a valid function in my installation.

here's output of php -m

```
[PHP Modules]
apcu
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gd
hash
iconv
imap
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pgsql
Phar
pspell
Reflection
session
SPL
sqlite3
standard
tokenizer
xml
xmlrpc
zip
zlib
```
Has anyone run into this issue and solved? Doing sort of - bull in the china shop troubleshooting I've rebuilt roundcube and its dependencies (most of php 7.2) from src (ports). help!

thanks
matt


----------



## obsigna (Nov 2, 2019)

Generally, this kind of error message about a missing function in PHP programs is quite common on FreeBSD. It usually means, that we need to add a missing module, and this would resolve the problem in most of the cases after restart of apache.

I got postfix+dovecot+apache+roundcube on FreeBSD 12.0-RELAESE-p11 systems working without any hickup together with php72. On one of those:

`# pkg version -v | grep php72`

```
mod_php72-7.2.24                   =   up-to-date with index
php72-7.2.24                       =   up-to-date with index
php72-bcmath-7.2.24                =   up-to-date with index
php72-ctype-7.2.24                 =   up-to-date with index
php72-curl-7.2.24                  =   up-to-date with index
php72-dom-7.2.24                   =   up-to-date with index
php72-exif-7.2.24                  =   up-to-date with index
php72-fileinfo-7.2.24              =   up-to-date with index
php72-filter-7.2.24                =   up-to-date with index
php72-hash-7.2.24                  =   up-to-date with index
php72-iconv-7.2.24                 =   up-to-date with index
php72-intl-7.2.24                  =   up-to-date with index
php72-json-7.2.24                  =   up-to-date with index
php72-mbstring-7.2.24              =   up-to-date with index
php72-mysqli-7.2.24                =   up-to-date with index
php72-openssl-7.2.24               =   up-to-date with index
php72-pdo-7.2.24                   =   up-to-date with index
php72-pdo_pgsql-7.2.24             =   up-to-date with index
php72-pdo_sqlite-7.2.24            =   up-to-date with index
php72-pgsql-7.2.24                 =   up-to-date with index
php72-phar-7.2.24                  =   up-to-date with index
php72-session-7.2.24               =   up-to-date with index
php72-sockets-7.2.24               =   up-to-date with index
php72-xml-7.2.24                   =   up-to-date with index
php72-zip-7.2.24                   =   up-to-date with index
php72-zlib-7.2.24                  =   up-to-date with index
roundcube-php72-1.3.10,1           =   up-to-date with index
```

I would have said, that php72-filter is missing in your case, but it appears in the list of registered php modules. Anyway, verify, if you really got the module installed. May it be, that on your system some parts of php56 were not removed properly - this may happen when you installed PHP in the past from sources out of the wild and not from the ports.

*PS: I just did a quick cross-check:*

`# pkg delete -f php72-filter`
`# service apache24 restart`

Now my webmail site does not open and in the httpd-error.log, I see:

```
[client 192.168.0.195:49420] PHP Fatal error:  Uncaught Error: Call to undefined function filter_var() in /usr/local/www/roundcube/program/lib/Roundcube/bootstrap.php:43
Stack trace:
   #0 /usr/local/www/roundcube/program/include/iniset.php(63): require_once()
   #1 /usr/local/www/roundcube/index.php(40): require_once('/usr/local/www/...')
   #2 {main}
      thrown in /usr/local/www/roundcube/program/lib/Roundcube/bootstrap.php on line 43
```

Since this is the same error like the one which you experienced, I am 100 % sure, that php72-filter is either not or not correctly installed on your server. Perhaps php -m shows a false positive entry for the filter module for some reason (unfortunate tweaks of php.ini!?).

For bringing my site back to normal, I just did:
`# /usr/ports/security/php72-filter`
`# make install clean`
`# service apache24 restart`


----------



## Barney (Nov 3, 2019)

THIS is why I always build PHP from source.


----------



## SirDice (Nov 4, 2019)

Roundcube works just fine with PHP 7.2. No need to build from sources.


```
root@mail:~ # pkg info -x php72
mod_php72-7.2.24
php72-7.2.24
php72-dom-7.2.24
php72-exif-7.2.24
php72-fileinfo-7.2.24
php72-filter-7.2.24
php72-gd-7.2.24
php72-iconv-7.2.24
php72-intl-7.2.24
php72-json-7.2.24
php72-mbstring-7.2.24
php72-openssl-7.2.24
php72-pdo-7.2.24
php72-pdo_mysql-7.2.24
php72-pspell-7.2.24
php72-session-7.2.24
php72-xml-7.2.24
php72-zip-7.2.24
roundcube-contextmenu-php72-2.3
roundcube-markasjunk2-php72-1.11.2
roundcube-php72-1.3.10,1
roundcube-sauserprefs-php72-1.10_1
roundcube-sieverules-php72-2.3,1
```


----------

