$this->setBlocker( $options['byText'] );
}
- $this->mReason = $options['reason'];
- $this->mTimestamp = wfTimestamp( TS_MW, $options['timestamp'] );
- $this->mExpiry = wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] );
+ $this->setReason( $options['reason'] );
+ $this->setTimestamp( wfTimestamp( TS_MW, $options['timestamp'] ) );
+ $this->setExpiry( wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] ) );
# Boolean settings
$this->mAuto = (bool)$options['auto'];
- $this->mHideName = (bool)$options['hideName'];
+ $this->setHideName( (bool)$options['hideName'] );
$this->isHardblock( !$options['anonOnly'] );
$this->isAutoblocking( (bool)$options['enableAutoblock'] );
$this->isSitewide( (bool)$options['sitewide'] );
&& $this->mAuto == $block->mAuto
&& $this->isHardblock() == $block->isHardblock()
&& $this->isCreateAccountBlocked() == $block->isCreateAccountBlocked()
- && $this->mExpiry == $block->mExpiry
+ && $this->getExpiry() == $block->getExpiry()
&& $this->isAutoblocking() == $block->isAutoblocking()
- && $this->mHideName == $block->mHideName
+ && $this->getHideName() == $block->getHideName()
&& $this->isEmailBlocked() == $block->isEmailBlocked()
&& $this->isUsertalkEditAllowed() == $block->isUsertalkEditAllowed()
- && $this->mReason == $block->mReason
+ && $this->getReason() == $block->getReason()
&& $this->isSitewide() == $block->isSitewide()
// Block::getRestrictions() may perform a database query, so keep it at
// the end.
$row->ipb_by, $row->ipb_by_text, $row->ipb_by_actor ?? null
) );
- $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
+ $this->setTimestamp( wfTimestamp( TS_MW, $row->ipb_timestamp ) );
$this->mAuto = $row->ipb_auto;
- $this->mHideName = $row->ipb_deleted;
+ $this->setHideName( $row->ipb_deleted );
$this->mId = (int)$row->ipb_id;
$this->mParentBlockId = $row->ipb_parent_block_id;
// I wish I didn't have to do this
$db = wfGetDB( DB_REPLICA );
- $this->mExpiry = $db->decodeExpiry( $row->ipb_expiry );
- $this->mReason = CommentStore::getStore()
+ $this->setExpiry( $db->decodeExpiry( $row->ipb_expiry ) );
+ $this->setReason(
+ CommentStore::getStore()
// Legacy because $row may have come from self::selectFields()
- ->getCommentLegacy( $db, 'ipb_reason', $row )->text;
+ ->getCommentLegacy( $db, 'ipb_reason', $row )->text
+ );
$this->isHardblock( !$row->ipb_anon_only );
$this->isAutoblocking( $row->ipb_enable_autoblock );
* @return array
*/
protected function getDatabaseArray( IDatabase $dbw ) {
- $expiry = $dbw->encodeExpiry( $this->mExpiry );
+ $expiry = $dbw->encodeExpiry( $this->getExpiry() );
if ( $this->forcedTargetID ) {
$uid = $this->forcedTargetID;
$a = [
'ipb_address' => (string)$this->target,
'ipb_user' => $uid,
- 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
+ 'ipb_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
'ipb_auto' => $this->mAuto,
'ipb_anon_only' => !$this->isHardblock(),
'ipb_create_account' => $this->isCreateAccountBlocked(),
'ipb_expiry' => $expiry,
'ipb_range_start' => $this->getRangeStart(),
'ipb_range_end' => $this->getRangeEnd(),
- 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite
+ 'ipb_deleted' => intval( $this->getHideName() ), // typecast required for SQLite
'ipb_block_email' => $this->isEmailBlocked(),
'ipb_allow_usertalk' => $this->isUsertalkEditAllowed(),
'ipb_parent_block_id' => $this->mParentBlockId,
'ipb_sitewide' => $this->isSitewide(),
- ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason )
+ ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
return $a;
protected function getAutoblockUpdateArray( IDatabase $dbw ) {
return [
'ipb_create_account' => $this->isCreateAccountBlocked(),
- 'ipb_deleted' => (int)$this->mHideName, // typecast required for SQLite
+ 'ipb_deleted' => (int)$this->getHideName(), // typecast required for SQLite
'ipb_allow_usertalk' => $this->isUsertalkEditAllowed(),
'ipb_sitewide' => $this->isSitewide(),
- ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason )
+ ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
}
# Check if the block is an autoblock and would exceed the user block
# if renewed. If so, do nothing, otherwise prolong the block time...
if ( $ipblock->mAuto && // @todo Why not compare $ipblock->mExpiry?
- $this->mExpiry > self::getAutoblockExpiry( $ipblock->mTimestamp )
+ $this->getExpiry() > self::getAutoblockExpiry( $ipblock->getTimestamp() )
) {
# Reset block timestamp to now and its expiry to
# $wgAutoblockExpiry in the future
wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" );
$autoblock->setTarget( $autoblockIP );
$autoblock->setBlocker( $this->getBlocker() );
- $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )
- ->inContentLanguage()->plain();
+ $autoblock->setReason(
+ wfMessage( 'autoblocker', $this->getTarget(), $this->getReason() )
+ ->inContentLanguage()->plain()
+ );
$timestamp = wfTimestampNow();
- $autoblock->mTimestamp = $timestamp;
+ $autoblock->setTimestamp( $timestamp );
$autoblock->mAuto = 1;
$autoblock->isCreateAccountBlocked( $this->isCreateAccountBlocked() );
# Continue suppressing the name if needed
- $autoblock->mHideName = $this->mHideName;
+ $autoblock->setHideName( $this->getHideName() );
$autoblock->isUsertalkEditAllowed( $this->isUsertalkEditAllowed() );
$autoblock->mParentBlockId = $this->mId;
$autoblock->isSitewide( $this->isSitewide() );
$autoblock->setRestrictions( $this->getRestrictions() );
- if ( $this->mExpiry == 'infinity' ) {
+ if ( $this->getExpiry() == 'infinity' ) {
# Original block was indefinite, start an autoblock now
- $autoblock->mExpiry = self::getAutoblockExpiry( $timestamp );
+ $autoblock->setExpiry( self::getAutoblockExpiry( $timestamp ) );
} else {
# If the user is already blocked with an expiry date, we don't
# want to pile on top of that.
- $autoblock->mExpiry = min( $this->mExpiry, self::getAutoblockExpiry( $timestamp ) );
+ $autoblock->setExpiry( min( $this->getExpiry(), self::getAutoblockExpiry( $timestamp ) ) );
}
# Insert the block...
$timestamp = wfTimestampNow();
wfDebug( "Block::isExpired() checking current " . $timestamp . " vs $this->mExpiry\n" );
- if ( !$this->mExpiry ) {
+ if ( !$this->getExpiry() ) {
return false;
} else {
- return $timestamp > $this->mExpiry;
+ return $timestamp > $this->getExpiry();
}
}
*/
public function updateTimestamp() {
if ( $this->mAuto ) {
- $this->mTimestamp = wfTimestamp();
- $this->mExpiry = self::getAutoblockExpiry( $this->mTimestamp );
+ $this->setTimestamp( wfTimestamp() );
+ $this->setExpiry( self::getAutoblockExpiry( $this->getTimestamp() ) );
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'ipblocks',
[ /* SET */
- 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
- 'ipb_expiry' => $dbw->timestamp( $this->mExpiry ),
+ 'ipb_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
+ 'ipb_expiry' => $dbw->timestamp( $this->getExpiry() ),
],
[ /* WHERE */
'ipb_id' => $this->getId(),
* @return int (0 for foreign users)
*/
public function getBy() {
- $blocker = $this->getBlocker();
- return ( $blocker instanceof User )
- ? $blocker->getId()
- : 0;
+ return $this->getBlocker()->getId();
}
/**
* @return string
*/
public function getByName() {
- $blocker = $this->getBlocker();
- return ( $blocker instanceof User )
- ? $blocker->getName()
- : (string)$blocker; // username
+ return $this->getBlocker()->getName();
}
/**
return $this;
}
+ /**
+ * Get the reason given for creating the block
+ *
+ * @since 1.33
+ * @return string
+ */
+ public function getReason() {
+ return $this->mReason;
+ }
+
+ /**
+ * Set the reason for creating the block
+ *
+ * @since 1.33
+ * @param string $reason
+ */
+ public function setReason( $reason ) {
+ $this->mReason = $reason;
+ }
+
+ /**
+ * Get whether the block hides the target's username
+ *
+ * @since 1.33
+ * @return bool The block hides the username
+ */
+ public function getHideName() {
+ return $this->mHideName;
+ }
+
+ /**
+ * Set whether ths block hides the target's username
+ *
+ * @since 1.33
+ * @param bool $hideName The block hides the username
+ */
+ public function setHideName( $hideName ) {
+ $this->mHideName = $hideName;
+ }
+
/**
* Get the system block type, if any
* @since 1.29
}
/**
- * @since 1.19
+ * Get the block expiry time
*
- * @return mixed|string
+ * @since 1.19
+ * @return string
*/
public function getExpiry() {
return $this->mExpiry;
}
+ /**
+ * Set the block expiry time
+ *
+ * @since 1.33
+ * @param string $expiry
+ */
+ public function setExpiry( $expiry ) {
+ $this->mExpiry = $expiry;
+ }
+
+ /**
+ * Get the timestamp indicating when the block was created
+ *
+ * @since 1.33
+ * @return string
+ */
+ public function getTimestamp() {
+ return $this->mTimestamp;
+ }
+
+ /**
+ * Set the timestamp indicating when the block was created
+ *
+ * @since 1.33
+ * @param string $timestamp
+ */
+ public function setTimestamp( $timestamp ) {
+ $this->mTimestamp = $timestamp;
+ }
+
/**
* Set the target for this block, and update $this->type accordingly
* @param mixed $target
$link = $blocker;
}
- $reason = $this->mReason;
+ $reason = $this->getReason();
if ( $reason == '' ) {
$reason = $context->msg( 'blockednoreason' )->text();
}
$context->getRequest()->getIP(),
$this->getByName(),
$systemBlockType ?? $this->getId(),
- $lang->formatExpiry( $this->mExpiry ),
+ $lang->formatExpiry( $this->getExpiry() ),
(string)$intended,
- $lang->userTimeAndDate( $this->mTimestamp, $context->getUser() ),
+ $lang->userTimeAndDate( $this->getTimestamp(), $context->getUser() ),
];
}