Page MenuHomePhabricator

"Use of undefined constant SOL_UDP" in 1.31 image while using wgStatsdServer
Open, Needs TriagePublic

Description

While using the 1.31 image and having $wgStatsdServer enabled / set to something I got

Warning: Use of undefined constant SOL_UDP - assumed 'SOL_UDP' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SocketSender.php on line 20

Looking at https://pear.php.net/bugs/bug.php?id=17473 it is provided by http://theserverpages.com/php/manual/en/function.socket-create.php for PHP5

Not sure about php7, we need to have a look

Event Timeline

ChristianHeusel subscribed.

Is this still a problem in recent Mediawiki versions? I didn't observe anything like this for my instances 🤔

I can reproduce this on Arch Linux (where the php-sockets extension isn’t packaged in the official repositories, and the AUR package is IIRC painful to build); under PHP 8, this is now a full error:

PHP Fatal error:  Uncaught Error: Undefined constant "Liuggio\StatsdClient\Sender\SOL_UDP" in /srv/http/wiki1/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SocketSender.php:20
Stack trace:
#0 /srv/http/wiki1/includes/MediaWikiEntryPoint.php(663): Liuggio\StatsdClient\Sender\SocketSender->__construct()
#1 /srv/http/wiki1/includes/db/MWLBFactory.php(442): MediaWiki\MediaWikiEntryPoint::emitBufferedStatsdData()
#2 /srv/http/wiki1/includes/libs/rdbms/database/Database.php(2072): MWLBFactory::{closure}()
#3 /srv/http/wiki1/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1560): Wikimedia\Rdbms\Database->runTransactionListenerCallbacks()
#4 /srv/http/wiki1/includes/libs/rdbms/lbfactory/LBFactory.php(383): Wikimedia\Rdbms\LoadBalancer->runPrimaryTransactionListenerCallbacks()
#5 /srv/http/wiki1/includes/libs/rdbms/lbfactory/LBFactory.php(352): Wikimedia\Rdbms\LBFactory->executePostTransactionCallbacks()
#6 /srv/http/wiki1/includes/exception/MWExceptionHandler.php(168): Wikimedia\Rdbms\LBFactory->rollbackPrimaryChanges()
#7 /srv/http/wiki1/includes/exception/MWExceptionHandler.php(193): MWExceptionHandler::rollbackPrimaryChanges()
#8 /srv/http/wiki1/includes/exception/MWExceptionHandler.php(236): MWExceptionHandler::rollbackPrimaryChangesAndLog()
#9 /srv/http/wiki1/includes/exception/MWExceptionHandler.php(205): MWExceptionHandler::handleException()
#10 [internal function]: MWExceptionHandler::handleUncaughtException()
#11 {main}
  thrown in /srv/http/wiki1/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SocketSender.php on line 20

Fatal error: Uncaught Error: Undefined constant "Liuggio\StatsdClient\Sender\SOL_UDP" in /srv/http/wiki1/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SocketSender.php on line 20

Error: Undefined constant "Liuggio\StatsdClient\Sender\SOL_UDP" in /srv/http/wiki1/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SocketSender.php on line 20

Arguably, liuggio/statsd-php-client should declare a dependency on "ext-sockets": "*" in its composer.json, similar to how MediaWiki requires ext-calendar, ext-dom, and others. (Although this would be slightly more painful for me, since then I’d have to actually install the extension to make composer happy, instead of just commenting out $wgStatsdServer ^^)

As for Docker-Hub-MediaWiki in particular – the extension probably needs to be installed there? (Assuming these images are still used.)

Noting that Upstream is basically abandonware at this point.

T326607: Future of liuggio/statsd-php-client?

I've just filed https://github.com/liuggio/statsd-php-client/issues/69 to document that both ext-sockets and ext-json should be in composer.json, but I'm not expecting anything from that.