Last modified: 2011-02-06 07:32:15 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 12135 - External links in templates cause a PHP in_array error
External links in templates cause a PHP in_array error
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Templates (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Raimond Spekking
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-28 01:04 UTC by Vince Castellano
Modified: 2011-02-06 07:32 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Vince Castellano 2007-11-28 01:04:59 UTC
When I put a URL like [http://example.com link] in a template, I get PHP error messages: 

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/html/w/includes/GlobalFunctions.php on line 1964

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/html/w/includes/GlobalFunctions.php on line 1966

The lines are as follows:
1964     if ( in_array( $bits['scheme'] . '://' , $wgUrlProtocols ) ) {
1965         $delimiter = '://';
1966     } elseif ( in_array( $bits['scheme'] .':' , $wgUrlProtocols ) ) {

I believe the issue is that $wgUrlProtocols is a string, containing a regex, and not an array, which in_array() requires. I checked svn, though I had a hard time navagating trunk, and assumed phase3 is the correct folder to check? If so, this is still the case in svn.
Comment 1 Tim Starling 2007-11-28 08:53:36 UTC
The bug was introduced in r20561. Raymond has offerred to fix this, along with some other problems he introduced with that commit. 

$wgUrlProtocols can be processed with code such as:

if ( is_array( $wgUrlProtocols ) ) {
    // 1.6+ format
    $protocols = $wgUrlProtocols;
} else {
    // pre-1.6 format
    $protocols = explode( '|', $wgUrlProtocols );
    foreach ( $protocols as $key => $protocol ) {
        $protocols[$key] = str_replace( '\/', '/', $key );
    }
}

The result should be saved to a static variable or similar, for efficiency. 
Comment 2 Tim Starling 2007-11-28 08:57:02 UTC
Note that you can work around the problem by changing $wgUrlProtocols in your LocalSettings.php to use the new format, e.g.:

$wgUrlProtocols = array(
	'http://',
	'https://',
	'ftp://',
	'irc://',
	'gopher://',
	'telnet://',
	'nntp://',
	'worldwind://',
	'mailto:',
	'news:'
);
Comment 3 Diederik van Liere 2011-02-06 07:32:15 UTC
It seems that this issue has been fixed.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links