aaron@svn.wikimedia.org wrote:
$limit = $wgRequest->getInt( 'limit', 50 );
global $wgFeedLimit;
if( $limit > $wgFeedLimit ) {
$limit = $wgFeedLimit;
}
This is a good candidate for refactoring into a common function...
-- brion
Something like a evil step brother to wfSetVar and wfSetBit?
function wfSetVarIf( &$dest, $source, $condition = '!=' ) { $temp = $dest; if ( !is_null( $source ) ) { $set = false; switch($condition) { case '!=':if($dest != $source) $dest = $source;break; case '>':if($dest > $source) $dest = $source;break; case '>=':if($dest >= $source) $dest = $source;break; case '<':if($dest < $source) $dest = $source;break; case '<=':if($dest <= $source) $dest = $source;break; } } return $temp; }
wfSetVarIf( $limit, $wgFeedLimit, '>' );
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
Brion Vibber wrote:
aaron@svn.wikimedia.org wrote:
$limit = $wgRequest->getInt( 'limit', 50 );
global $wgFeedLimit;
if( $limit > $wgFeedLimit ) {
$limit = $wgFeedLimit;
}
This is a good candidate for refactoring into a common function...
-- brion
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
DanTMan wrote:
Something like a evil step brother to wfSetVar and wfSetBit?
Nope, more like a nice feed-specific version of WebRequest::getLimitOffset() so the limit checks don't have to be duplicated in fifty places.
-- brion
Op Saturday 17 May 2008 18:10:58 schreef Brion Vibber:
aaron@svn.wikimedia.org wrote:
$limit = $wgRequest->getInt( 'limit', 50 );
global $wgFeedLimit;
if( $limit > $wgFeedLimit ) {
$limit = $wgFeedLimit;
}
This is a good candidate for refactoring into a common function...
How about $limit = min( $limit, $wgFeedLimit ); or $limit = min( $wgRequest->getInt( 'limit', 50 ), $wgFeedLimit ); ?
Jelte
Sounds good to me.
Jelte-2 wrote:
Op Saturday 17 May 2008 18:10:58 schreef Brion Vibber:
aaron@svn.wikimedia.org wrote:
$limit = $wgRequest->getInt( 'limit', 50 );
global $wgFeedLimit;
if( $limit > $wgFeedLimit ) {
$limit = $wgFeedLimit;
}
This is a good candidate for refactoring into a common function...
How about $limit = min( $limit, $wgFeedLimit ); or $limit = min( $wgRequest->getInt( 'limit', 50 ), $wgFeedLimit ); ?
Jelte
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org