+ $this->show( wfMsg( 'sessionfailure' ) );
+ return false;
+ }
+
+ if ( strlen( $this->mExpiry ) == 0 ) {
+ $this->mExpiry = 'infinite';
+ }
+
+ if ( $this->mExpiry == 'infinite' || $this->mExpiry == 'indefinite' ) {
+ $expiry = Block::infinity();
+ } else {
+ # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
+ $expiry = strtotime( $this->mExpiry );
+
+ if ( $expiry < 0 || $expiry === false ) {
+ $this->show( wfMsg( 'protect_expiry_invalid' ) );
+ return false;
+ }
+
+ // Fixme: non-qualified absolute times are not in users specified timezone
+ // and there isn't notice about it in the ui
+ $expiry = wfTimestamp( TS_MW, $expiry );
+
+ if ( $expiry < wfTimestampNow() ) {
+ $this->show( wfMsg( 'protect_expiry_old' ) );
+ return false;
+ }
+
+ }
+
+ # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
+ # to a semi-protected page.
+ global $wgGroupPermissions;
+
+ $edit_restriction = $this->mRestrictions['edit'];
+
+ if ($this->mCascade && ($edit_restriction != 'protect') &&
+ !(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) )
+ $this->mCascade = false;
+
+ if ($this->mTitle->exists()) {
+ $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry );
+ } else {
+ $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry );