Page MenuHomePhabricator

Fix the display of blocks and contributions if they are unavailable [M]
Closed, ResolvedPublic

Assigned To
Authored By
Jan 7 2022, 3:45 PM
Referenced Files
F34929931: no_edit_info.png
Jan 25 2022, 9:56 AM
F34929934: no_both_info.png
Jan 25 2022, 9:56 AM
F34929929: no_block_info.png
Jan 25 2022, 9:56 AM
F34928871: screenshot.png
Jan 24 2022, 1:31 PM
F34928862: screenshot.png
Jan 24 2022, 1:31 PM
F34914576: screenshot.png
Jan 11 2022, 4:41 PM
F34910520: screenshot.png
Jan 7 2022, 3:45 PM


If any of the IP Info data are unavailable, they are displayed as Not available.

This is currently not working for the blocks and contribs properties.

Steps to reproduce

  • Make the blocks and contributions info unavailable by setting the following config:
$wgGroupPermissions['sysop']['ipinfo'] = true;
$wgGroupPermissions['sysop']['ipinfo-view-full'] = false;
$wgGroupPermissions['sysop']['ipinfo-view-basic'] = false;
  • Log in as an admin and view either the infobox or the popup
  • Expected:

screenshot.png (237×325 px, 18 KB)

  • Actual:

screenshot.png (260×327 px, 16 KB)

The problem is here (link to code):

var activeBlocks = mw.msg( 'ipinfo-value-active-blocks',[ 'ipinfo-source-block' ].numActiveBlocks );
var localEdits = mw.msg( 'ipinfo-value-local-edits',[ 'ipinfo-source-contributions' ].numLocalEdits );
var $recentEdits = $( '<span>' ).addClass( 'ext-ipinfo-widget-value-recent-edits' )
	.append( mw.msg( 'ipinfo-value-recent-edits',[ 'ipinfo-source-contributions' ].numRecentEdits ) );
var $edits = $( '<span>' ).append(
	$( '<br>' ),
return $( '<dl>' ).addClass( 'ext-ipinfo-widget-property-properties' ).append(
	this.generatePropertyMarkup( location, mw.msg( 'ipinfo-property-label-location' ) ),
	this.generatePropertyMarkup([ 'ipinfo-source-geoip2' ].organization, mw.msg( 'ipinfo-property-label-organization' ) ),
	this.generatePropertyMarkup( activeBlocks, mw.msg( 'ipinfo-property-label-active-blocks' ) ),
	this.generatePropertyMarkup( $edits, mw.msg( 'ipinfo-property-label-edits' ) )

When[ 'ipinfo-source-block' ] and[ 'ipinfo-source-contributions' ] are undefined, we should not pass the message translations to generatePropertyMarkup. Instead we should pass null.

Acceptance criteria

If the blocks and/or contribs properties are unavailable, they should display as Not available in the popup and infobox.

Event Timeline

Change 752637 had a related patch set uploaded (by Wikitrent; author: Wikitrent):

[mediawiki/extensions/IPInfo@master] WIP: Return 'null' when blocks and contribs are undefined

My WIP patch is to see if I'm going in the right direction for this bug or if there's a code style/convention I'm not following to fix this properly.

See this follow-up task about what we should do if only one of local edits or recent edits are available (and the other is not): T299654: Investigate: Should we return individual values for local and recent edits?

If only one is available, it currently looks like this:

Recent edits unavailableLocal edits unavailable
screenshot.png (156×160 px, 7 KB)
screenshot.png (153×172 px, 9 KB)

(In theory this shouldn't happen unless something goes wrong - either both should be available or neither should be available, depending on permissions.)

Change 752637 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Pass 'undefined' when blocks and contribs are undefined

dom_walden subscribed.

Here is how it looks now:

Without block info:

no_block_info.png (244×327 px, 15 KB)

Without edit info:

no_edit_info.png (228×326 px, 16 KB)

Without either:

no_both_info.png (227×328 px, 15 KB)

I was working under the assumption that when the information is unavailable the API returns an empty string ([]) rather than something like a null or false[1].

Test Environment: local docker IP Info 0.0.0 (2597bfa) 16:38, 24 January 2022.


  1. When I did experiment having the API return null there was an error in the browser console: jQuery.Deferred exception:['ipinfo-source-contributions'] is null. It does not seem to mind if false is returned, however, displaying it as Not available.