* @return array
*/
function wfArrayFilter( array $arr, callable $callback ) {
+ wfDeprecated( __FUNCTION__, '1.32' );
return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
}
* @return array
*/
function wfArrayFilterByKey( array $arr, callable $callback ) {
+ wfDeprecated( __FUNCTION__, '1.32' );
return array_filter( $arr, $callback, ARRAY_FILTER_USE_KEY );
}
*
* @param array $array The array.
* @param array $insert The array to insert.
- * @param mixed $after The key to insert after
+ * @param mixed $after The key to insert after. Callers need to make sure the key is set.
* @return array
*/
function wfArrayInsertAfter( array $array, array $insert, $after ) {
}
/**
- * Get a random decimal value between 0 and 1, in a way
+ * Get a random decimal value in the domain of [0, 1), in a way
* not likely to give duplicate values for any realistic
* number of articles.
*
}
// Add parameter
- if ( false === strpos( $url, '?' ) ) {
+ if ( strpos( $url, '?' ) === false ) {
$url .= '?';
} else {
$url .= '&';
/**
* Make URL indexes, appropriate for the el_index field of externallinks.
*
+ * @deprecated since 1.33, use LinkFilter::makeIndexes() instead
* @param string $url
* @return array
*/
function wfMakeUrlIndexes( $url ) {
- $bits = wfParseUrl( $url );
-
- // Reverse the labels in the hostname, convert to lower case
- // For emails reverse domainpart only
- if ( $bits['scheme'] == 'mailto' ) {
- $mailparts = explode( '@', $bits['host'], 2 );
- if ( count( $mailparts ) === 2 ) {
- $domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) );
- } else {
- // No domain specified, don't mangle it
- $domainpart = '';
- }
- $reversedHost = $domainpart . '@' . $mailparts[0];
- } else {
- $reversedHost = strtolower( implode( '.', array_reverse( explode( '.', $bits['host'] ) ) ) );
- }
- // Add an extra dot to the end
- // Why? Is it in wrong place in mailto links?
- if ( substr( $reversedHost, -1, 1 ) !== '.' ) {
- $reversedHost .= '.';
- }
- // Reconstruct the pseudo-URL
- $prot = $bits['scheme'];
- $index = $prot . $bits['delimiter'] . $reversedHost;
- // Leave out user and password. Add the port, path, query and fragment
- if ( isset( $bits['port'] ) ) {
- $index .= ':' . $bits['port'];
- }
- if ( isset( $bits['path'] ) ) {
- $index .= $bits['path'];
- } else {
- $index .= '/';
- }
- if ( isset( $bits['query'] ) ) {
- $index .= '?' . $bits['query'];
- }
- if ( isset( $bits['fragment'] ) ) {
- $index .= '#' . $bits['fragment'];
- }
-
- if ( $prot == '' ) {
- return [ "http:$index", "https:$index" ];
- } else {
- return [ $index ];
- }
+ wfDeprecated( __FUNCTION__, '1.33' );
+ return LinkFilter::makeIndexes( $url );
}
/**
/**
* Throws a warning that $function is deprecated
*
- * @param string $function
+ * @param string $function Function that is deprecated.
* @param string|bool $version Version of MediaWiki that the function
* was deprecated in (Added in 1.19).
- * @param string|bool $component Added in 1.19.
+ * @param string|bool $component Component to which the function belongs.
+ * If false, it is assumed the function is in MediaWiki core (Added in 1.19).
* @param int $callerOffset How far up the call stack is the original
* caller. 2 = function that called the function that called
- * wfDeprecated (Added in 1.20)
- *
- * @return null
+ * wfDeprecated (Added in 1.20).
*/
function wfDeprecated( $function, $version = false, $component = false, $callerOffset = 2 ) {
MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
/**
* Get a load balancer object.
*
- * @deprecated since 1.27, use MediaWikiServices::getDBLoadBalancer()
- * or MediaWikiServices::getDBLoadBalancerFactory() instead.
+ * @deprecated since 1.27, use MediaWikiServices::getInstance()->getDBLoadBalancer()
+ * or MediaWikiServices::getInstance()->getDBLoadBalancerFactory() instead.
*
* @param string|bool $wiki Wiki ID, or false for the current wiki
* @return \Wikimedia\Rdbms\LoadBalancer
/**
* Get the load balancer factory object
*
- * @deprecated since 1.27, use MediaWikiServices::getDBLoadBalancerFactory() instead.
+ * @deprecated since 1.27, use MediaWikiServices::getInstance()->getDBLoadBalancerFactory() instead.
*
* @return \Wikimedia\Rdbms\LBFactory
*/
function wfCanIPUseHTTPS( $ip ) {
$canDo = true;
Hooks::run( 'CanIPUseHTTPS', [ $ip, &$canDo ] );
- return !!$canDo;
+ return (bool)$canDo;
}
/**