}
}
+ /**
+ * If the wiki is currently in readonly mode, throws a ReadOnlyError
+ *
+ * @since 1.19
+ * @throws ReadOnlyError
+ */
+ public function checkReadOnly() {
+ if ( wfReadOnly() ) {
+ throw new ReadOnlyError;
+ }
+ }
+
/**
* Sets headers - this should be called from the execute() method of all derived classes!
*/
/**
* Shortcut to get user's language
*
+ * @deprecated 1.19 Use getLanguage instead
* @return Language
* @since 1.18
*/
public function getLang() {
- return $this->getContext()->getLang();
+ return $this->getLanguage();
+ }
+
+ /**
+ * Shortcut to get user's language
+ *
+ * @return Language
+ * @since 1.19
+ */
+ public function getLanguage() {
+ return $this->getContext()->getLanguage();
}
/**
* @throws ErrorPageError
*/
protected function checkExecutePermissions( User $user ) {
- if ( $this->requiresWrite() && wfReadOnly() ) {
- throw new ReadOnlyError();
- }
-
- if ( !$this->userCanExecute( $this->getUser() ) ) {
- throw new PermissionsError( $this->getRestriction() );
- }
+ $this->checkPermissions();
if ( $this->requiresUnblock() && $user->isBlocked() ) {
$block = $user->mBlock;
throw new UserBlockedError( $block );
}
+ if ( $this->requiresWrite() ) {
+ $this->checkReadOnly();
+ }
+
return true;
}