Page MenuHomePhabricator

PHP Fatal error: Call to a member function setLogger() on null (if $wgExtDistAPIConfig not set)
Open, Needs TriagePublic

Description

Hi I'm getting this error in my error_log

[30-Mar-2016 04:14:02 UTC] PHP Fatal error: Call to a member function setLogger() on null in /home/randomwi/public_html/pt-br/extensions/ExtensionDistributor/includes/api/ApiListExtDistBranches.php on line 35

Event Timeline

Change 280510 had a related patch set uploaded (by Paladox):
Fix Call to a member function setLogger() on null

https://gerrit.wikimedia.org/r/280510

Change 280510 abandoned by Paladox:
Fix Call to a member function setLogger() on null

https://gerrit.wikimedia.org/r/280510

@Paladox looks like you haven't configured $wgExtDistAPIConfig:
./includes/providers/ExtDistProvider.php:

	/**
	 * Get the provider configured for the given type
	 *
	 * @param string $type
	 * @return ExtDistProvider
	 */
	public static function getProviderFor( $type ) {
		global $wgExtDistAPIConfig;
		if ( !$wgExtDistAPIConfig ) {
			return null;
		}
		return self::factory(
			$wgExtDistAPIConfig + array( 'repoType' => $type )
		);
	}

Because the API is trying to call setLogger() on a null object by ExtDistProvider::getProviderFor() (which is only null if $wgExtDistAPIConfig is not set), it returns this error.

If you visit Special:BaseDistributor, you should see the extdist-not-configured wikimsg, because you lack this config.

Oh ok, thanks for spotting that. Could this been fixed so that we can leave it blank please.

The extension shouldn't fail with a random fatal error from PHP if not configured, we should detect these cases and throw a custom exception with a relevant helpful message describing how to fix it.

Aklapper renamed this task from PHP Fatal error: Call to a member function setLogger() on null to PHP Fatal error: Call to a member function setLogger() on null (if $wgExtDistAPIConfig not set).Apr 3 2016, 9:04 AM

Change 366463 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/extensions/ExtensionDistributor@master] More obviously fail if $wgExtDistAPIConfig isn't set

https://gerrit.wikimedia.org/r/366463

Change 366463 abandoned by Legoktm:
More obviously fail if $wgExtDistAPIConfig isn't set

Reason:
I'll follow up on this later

https://gerrit.wikimedia.org/r/366463

Reedy changed the task status from Open to Stalled.Apr 7 2020, 1:15 AM
Reedy removed a project: Patch-For-Review.
Reedy subscribed.

Is this still a problem?

Dylsss changed the task status from Stalled to Open.Mar 18 2022, 1:04 AM
Dylsss subscribed.

Is this still a problem?

This is still reproducible.

Change 771750 had a related patch set uploaded (by Dylsss; author: Dylsss):

[mediawiki/extensions/ExtensionDistributor@master] Clearly error if $wgExtDistAPIConfig is not set

https://gerrit.wikimedia.org/r/771750