Occ no longer working with PHP 7.0.31

I’m running Nextcloud 13.0.6 on OpenBSD current, with httpd and PHP 7.0.31, and postgresql 10.5 on the database. Everything in both the browser and the android client runs fine, but the occ command no longer works on the cli – complains about db connectivity. All the correct modules are installed, database is up, etc. What else might cause this?

# doas -u www /usr/local/bin/php-7.0 /storage/www/nextcloud/occ

An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /storage/www/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /storage/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()                                                             
#1 /storage/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()                                  
#2 /storage/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()                                      
#3 /storage/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()                                         
#4 /storage/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)                                                              
#5 /storage/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /storage/www/nextcloud/lib/private/DB/ConnectionFactory.php(152): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /storage/www/nextcloud/lib/private/Server.php(628): OC\DB\ConnectionFactory->getConnection('pgsql', Array)                                                                   
#8 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))                                                      
#9 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IDBConnecti...')                                         
#10 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IDBConnecti...')                                          
#11 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IDBConnecti...')                                          
#12 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))  
#13 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('DatabaseConnect...')                                         
#14 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')                                           
#15 /storage/www/nextcloud/lib/private/Server.php(1511): OC\ServerContainer->query('DatabaseConnect...')                                                                        
#16 /storage/www/nextcloud/lib/private/Server.php(332): OC\Server->getDatabaseConnection()                                                                                      
#17 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))                                                     
#18 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')                                        
#19 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')                                          
#20 /storage/www/nextcloud/lib/private/Server.php(336): OC\ServerContainer->query('OC\\Authenticati...')                                                                        
#21 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))                                                     
#22 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')                                        
#23 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')                                          
#24 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\Authenticati...')                                          
#25 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))  
#26 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')                                        
#27 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')                                          
#28 /storage/www/nextcloud/lib/private/Server.php(352): OC\ServerContainer->query('OC\\Authenticati...')
#29 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#30 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IUserSessio...')
#31 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IUserSessio...')
#32 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IUserSessio...')
#33 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#34 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('UserSession')
#35 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#36 /storage/www/nextcloud/lib/private/Server.php(1380): OC\ServerContainer->query('UserSession')
#37 /storage/www/nextcloud/lib/private/Server.php(688): OC\Server->getUserSession()
#38 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#39 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#40 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\App\\AppManag...')
#41 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\App\\AppManag...')
#42 /storage/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#43 /storage/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('AppManager')
#44 /storage/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#45 /storage/www/nextcloud/lib/private/Server.php(1684): OC\ServerContainer->query('AppManager')
#46 /storage/www/nextcloud/lib/private/legacy/app.php(332): OC\Server->getAppManager()
#47 /storage/www/nextcloud/lib/private/legacy/app.php(113): OC_App::getEnabledApps()
#48 /storage/www/nextcloud/lib/base.php(662): OC_App::loadApps(Array)
#49 /storage/www/nextcloud/lib/base.php(1081): OC::init()
#50 /storage/www/nextcloud/console.php(46): require_once('/storage/www/ne...')
#51 /storage/www/nextcloud/occ(11): require_once('/storage/www/ne...')
#52 {main}
# php -m

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
mysqlnd
openssl
pcntl
pcre
PDO
pdo_pgsql
pgsql
Phar
posix
readline
redis
Reflection
session
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

EDIT to include:

# cat /etc/php-7.0.ini

[PHP]
user_ini.filename = ".htaccess"
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 4092M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
include_path = ".:/pear/lib:/var/www/pear/lib"
doc_root =
user_dir =
extension_dir = "/usr/local/lib/php-7.0/modules"
enable_dl = Off
file_uploads = On
upload_max_filesize = 4096M
max_file_uploads = 50
allow_url_fopen = True
allow_url_include = Off

extension=bz2.so
extension=curl.so
extension=gd.so
extension=intl.so
extension=mcrypt.so
zend_extension=opcache.so
extension=pcntl.so
extension=pdo_pgsql.so
extension=pgsql.so

[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
extension=redis.so
extension=xmlrpc.so
extension=zip.so

php -m is perhaps a different program from /usr/local/bin/php-7.0! Perhaps there is a second php setup. Can you try to get the php7.0 -m output? From the output, it’s quite obvious that you are missing certain modules.

After updating to 14.0.0, I have a new issue – I’ve added my notes onto this thread: Class defaultTokenProvider does not exist.

However, I’ll leave this here for good measure:

# pkg_info | grep php
php-7.0.32          server-side HTML-embedded scripting language
php-bz2-7.0.32      bzip2 compression extensions for php
php-curl-7.0.32     curl URL library extensions for php
php-gd-7.0.32       image manipulation extensions for php
php-intl-7.0.32     intl library support for php
php-mcrypt-7.0.32   mcrypt encryption/decryption extensions for php
php-pcntl-7.0.32    PCNTL extensions for php
php-pdo_pgsql-7.0.32 PDO pgsql database access extensions for php
php-pgsql-7.0.32    pgsql database access extensions for php
php-xmlrpc-7.0.32   XML RPC functions for php
php-zip-7.0.32      zip functions for php
# which php
/usr/local/bin/php
# ls -l /usr/local/bin/php*                                                                                                                                            
lrwxr-x---  1 root  wheel        22 May 22 22:26 /usr/local/bin/php@ -> /usr/local/bin/php-7.0
-rwxr-xr-x  1 root  bin    10836064 Sep 19 01:31 /usr/local/bin/php-7.0*

This original issue was caused by setting root’s umask to 027. During an upgrade of php’s pgsql module package, a handful of files that are created on the fly during package installation had these restricted permissions set. Afterwards, the www user could no longer access the php pgsql module.