function __construct( $address = '', $user = 0, $by = 0, $reason = '',
$timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
- $hideName = 0, $blockEmail = 0, $allowUsertalk = 0 )
+ $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byName = false )
{
$this->mId = 0;
# Expand valid IPv6 addresses
$this->mAllowUsertalk = $allowUsertalk;
$this->mForUpdate = false;
$this->mFromMaster = false;
- $this->mByName = false;
+ $this->mByName = $byName;
$this->mAngryAutoblock = false;
$this->initialiseRange();
}
$options = array();
$db =& $this->getDBOptions( $options );
- if ( 0 == $user && $address == '' ) {
+ if ( 0 == $user && $address === '' ) {
# Invalid user specification, not blocked
$this->clear();
return false;
# Try IP block
# TODO: improve performance by merging this query with the autoblock one
# Slightly tricky while handling killExpired as well
- if ( $address ) {
+ if ( $address !== '' ) {
$conds = array( 'ipb_address' => $address, 'ipb_auto' => 0 );
$res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) );
*
* @return Boolean: whether or not the insertion was successful.
*/
- public function insert() {
+ public function insert( $dbw = null ) {
wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" );
- $dbw = wfGetDB( DB_MASTER );
+ if ( $dbw === null )
+ $dbw = wfGetDB( DB_MASTER );
$this->validateBlockParams();
$this->initialiseRange();
'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ),
'ipb_range_start' => $this->mRangeStart,
'ipb_range_end' => $this->mRangeEnd,
- 'ipb_deleted' => $this->mHideName,
+ 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite
'ipb_block_email' => $this->mBlockEmail,
'ipb_allow_usertalk' => $this->mAllowUsertalk
),