Page MenuHomePhabricator

PHP Notice: Use of undefined constant
Closed, DeclinedPublic

Description

Setup:
MW 1.25.2, PHP 5.4.45, TitleBlacklist REL1_25

Issue:
I get the following notices

PHP Notice:  Use of undefined constant TBLSRC_LOCALPAGE - assumed 'TBLSRC_LOCALPAGE' in /.../w/LocalSettings.php on line 512
PHP Notice:  Use of undefined constant TBLSRC_URL - assumed 'TBLSRC_URL' in /.../w/LocalSettings.php on line 516

when LocalSettings.php contains "wfLoadExtension":

## TitleBlacklist
wfLoadExtension( 'TitleBlacklist' );
$wgTitleBlacklistSources = array(
	array(
		'type' => TBLSRC_LOCALPAGE,
		'src'  => 'MediaWiki:Titleblacklist',
		),
	array(
		'type' => TBLSRC_URL,
		'src'  => 'https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw',
		),
	);

while line 512 and 516 are the ones with 'src'.

No warnings when LocalSettings.php directly invokes:

## TitleBlacklist
require_once "$IP/extensions/TitleBlacklist/TitleBlacklist.php";
$wgTitleBlacklistSources = array(
	array(
		'type' => TBLSRC_LOCALPAGE,
		'src'  => 'MediaWiki:Titleblacklist',
		),
	array(
		'type' => TBLSRC_URL,
		'src'  => 'https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw',
		),
	);

Event Timeline

Kghbln raised the priority of this task from to Needs Triage.
Kghbln updated the task description. (Show Details)
Kghbln added a project: TitleBlacklist.
Kghbln subscribed.

I would like to use the new mechanism to invoke this extension without spamming my error log. Thus it will be great if someone could have a peep at this. Thanks and cheeers

Glaisher claimed this task.
Glaisher subscribed.

Those constants are not available in the new registration system. So you need to use use the constants' values directly instead. See https://phabricator.wikimedia.org/diffusion/ETBL/browse/master/TitleBlacklist.php;d8f93f3d63d6715d9fd5f3cadb67c18146157083$5

@Glaisher

Thanks a ton for clarifying: So when adding the following to "LocalSettings.php" I indeed do no longer get these PHP Notices:

wfLoadExtension( 'TitleBlacklist' );
$wgTitleBlacklistSources = array(
	'http://www.example.org/w/index.php?title=MediaWiki:Titleblacklist&action=raw',
	'https://www.mediawiki.org/wiki/MediaWiki:Titleblacklist&action=raw',
	'https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw'
	);

The only thing I still have to figure out is why only the local Titleblacklist works, but that's probably another story. I will adjust the extension's documentation accordingly.

@Glaisher

I have just just documented this. It will be nice if you could have a peep at it.

Actually it should be like the following (note that the constants' values are directly used):

$wgTitleBlacklistSources = array(
	array(
		'type' => 'localpage',
		'src'  => 'MediaWiki:Titleblacklist',
		),
	array(
		'type' => 'url',
		'src'  => 'https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw',
		),
	);

Sorry I was unclear on that part. I guess that's why only the local blacklist works. I've also updated the documentation.

Ah, I get it. Thank you! Since I am not a coder I misinterpreted your comment.

This does not solve the issue why external urls do not work, still only the local one steps in but this is another story and does not belong in this task.

Could you open a new bug with error logs and anything else that could be helpful with debugging?

Yep, I have created T129492 for this. Hopefully it is just a tiny issue.