4

I have difficulty upgrading Mediawiki from 1.23 to 1.25 owing to StatsdDataFactory.

I succeeded in "composer update" and "php update.php." But when I tried "php rebuildall.php", I got the following error:

PHP Fatal error: Class 'Liuggio\StatsdClient\Factory\StatsdDataFactory' not found in /var/www/html/mydomain.com/w/includes/libs/BufferingStatsdDataFactory.php on line 33

The same error occurred both in

(1) CentOS 6.6 + PHP 5.3.3 + Apache 2.2.15 + mysql 14.1

and in

(2) CentOS 7.1 + PHP 5.4.16 + Apache 2.4.6 + mariadb 15.1

I opened the BufferingStatsdDataFactory.php file.

(line 23) use Liuggio\StatsdClient\Factory\StatsdDataFactory;

(line 33) class BufferingStatsdDataFactory extends StatsdDataFactory { protected $buffer = array(); ...

Then I opened composer.json at /var/www/html/mydomain.com/w/, to find "liuggio/statsd-php-client" is included.

    "require": {
            "cssjanus/cssjanus": "1.1.1",
            "ext-iconv": "*",
            "leafo/lessphp": "0.5.0",
            "liuggio/statsd-php-client": "1.0.12",
            "oojs/oojs-ui": "0.11.3",
            "php": ">=5.3.3",
            "psr/log": "1.0.0",
            "wikimedia/cdb": "1.0.1",
            "wikimedia/composer-merge-plugin": "1.0.0",
            "wikimedia/utfnormal": "1.0.2",
            "zordius/lightncandy": "0.18"
    },

In this file, I imitated the solution shown here (PHP Fatal error: Class 'MyApp\Chat' not found in /MyApp/chat-server.php).

    "autoload": {
            "psr-0": {
                    "ComposerHookHandler": "includes/composer"
            }
            "psr-4": {
                    "Liuggio\\": "includes/composer"
            }

},

But it did not work. The following did not work either.

            "psr-4": {
                    "Liuggio\\": ""
            }

When I commented out the BufferingStatsdDataFactory.php, I got another error:

PHP Fatal error: Class 'BufferingStatsdDataFactory' not found in /var/www/html/mydomain.com/w/includes/context/RequestContext.php on line 137

Now my wiki site is inaccessible. I welcome any suggestions.

Community
  • 1
  • 1

7 Answers7

4

Check the vendor/liuggio/statsd-php-client directory. If the classes are not there, you have some kind of Composer problem. If the classes are there, they are probably not included in the file used by Composer to map class names to file paths. (Depending on its configuration, Composer can either locate files on the fly by traversing directories according to the fully qualified class name, or improve autoloading performance a bit by storing a complete class => path mapping in a file. If the autloader is configured one way and the update command which has to regenerate the classmap the other way, you get errors like this.) To fix that, run composer dump-autoload --optimize.

Tgr
  • 27,442
  • 12
  • 81
  • 118
2

I found that unzipping the mediawiki-n-n.tar.gz file in Windows via 7Zip or PeaZip caused corrupted file names -- not just under vendor/liuggio/statsd-php-client, but also under resources/src/mediawiki.rcfilters/* and others.

The extracted files were missing the last parts of their names, e.g.:

mw.rcfilters.ui.FilterItemHighlightButton.le
mw.rcfilters.ui.FilterMenuHeaderWidget.l
mw.rcfilters.ui.FilterMenuOptionWidget.les
mw.rcfilters.ui.FilterMenuOptionWidg

instead of:

mw.rcfilters.ui.FilterItemHighlightButton.less
mw.rcfilters.ui.FilterMenuHeaderWidget.less
mw.rcfilters.ui.FilterMenuOptionWidget.less
mw.rcfilters.ui.FilterMenuOptionWidget.monobook.less

I found incorrect files under extensions/, resources/, tests/ and vendor/.

Once I switched to cywgin tar to unzip the mediawiki-n-n.tar.gz archive, the filenames were correct.

So if you're seeing this error: it's not just vendor/liuggio/statsd-php-client that's broken, there are likely other parts of your extracted archive that are incorrect from 7Zip/PeaZip. I'd suggest you unzip with cygwin's tar instead.

NicJ
  • 4,070
  • 1
  • 25
  • 18
  • The problem still exists in 2022 with MediaWiki 1.38.2 and Ubuntu 18.04 LTS. It looks like the `.tar.gz` version is corrupted. but `.zip` seems to work. – Miki Aug 29 '22 at 13:58
1

Has been filled as https://phabricator.wikimedia.org/T123569 . Seems you just need to run composer update.

1

From https://phabricator.wikimedia.org/T123569 the article Antoine 'hashar' Musso references (thanks), Once you download the composer patch at: https://gerrit.wikimedia.org/r/#/c/264072/, I copied the folder:

composer/liuggio/statsd-php-client

and overwrote the:

vendor/liuggio/statsd-php-client

folder in my mediawiki site and the missing class was now found. - Fixed!
The mediawiki fresh install only had the interface and was missing the class.

Dr. Aaron Dishno
  • 1,859
  • 1
  • 29
  • 24
  • 1
    Gerrit interface is not that welcoming for downloading. Found the github repo and replaced the directory manually. https://github.com/liuggio/statsd-php-client – nasirkhan Jan 05 '21 at 18:12
1

This is ages old, but I got to struggle with this just today with the newest distribution of MediaWiki. Nothing helped, unpacking MediaWiki archive locally nor server-side. Basically statsd-php-client library files are notoriously corrupted during untaring process. What you need to do is go to this Git repo https://github.com/liuggio/statsd-php-client/ and download the library manually, then uzip it and copy the contents to vendor/liuggio/statsd-php-client folder in your MediaWiki directory. Hope it saves someone the struggle.

Dominika
  • 11
  • 2
0

Quick note: I was getting the same error but due to the web host I was using I was unable to run the composer update. Further googling indicated that it might have been due to the decompression misbehaving on my web host. I just decompressed the mediawiki file locally on my MacBook Pro, FTP'd all the files up and that resolved my problem.

Vincent
  • 1
  • 1
0

I faced this issue in Mediawiki 1.35.1. This issues existed so long and no one from the core team cared to resolve this. I had to spent an hour to install on a windows machine today.

Downloaded the files form the Github repo https://github.com/liuggio/statsd-php-client and replaces with the current one.

For this issue I had to replace the contents of the mediawiki_installation_directory\vendor\liuggio with the downloaded files form the https://github.com/liuggio/statsd-php-client

nasirkhan
  • 9,948
  • 5
  • 27
  • 33