54 parent::__construct(
'Redirect' );
65 $parts = $subpage !==
null ? explode(
'/', $subpage, 2 ) : [];
66 $this->mType = $parts[0] ??
null;
67 $this->mValue = $parts[1] ??
null;
76 if ( !ctype_digit( $this->mValue ) ) {
77 return Status::newFatal(
'redirect-not-numeric' );
79 $user = $this->userFactory->newFromId( (
int)$this->mValue );
81 if ( $user->isAnon() ) {
82 return Status::newFatal(
'redirect-not-exists' );
84 if ( $user->isHidden() && !$this->getAuthority()->isAllowed(
'hideuser' ) ) {
88 return Status::newGood( [
89 $user->getUserPage()->getFullURL(
'',
false,
PROTO_CURRENT ), 302
100 $title = Title::newFromTextThrow( $this->mValue,
NS_FILE );
101 if ( $title && !$title->inNamespace(
NS_FILE ) ) {
103 $title = Title::newFromTextThrow( Title::makeName(
NS_FILE, $this->mValue ) );
108 $file = $this->repoGroup->findFile( $title );
110 if ( !$file || !$file->exists() ) {
111 return Status::newFatal(
'redirect-not-exists' );
114 $url = $file->getUrl();
116 $width = $request->getInt(
'width', -1 );
117 $height = $request->getInt(
'height', -1 );
120 if ( $width != -1 ) {
121 $mto = $file->transform( [
'width' => $width,
'height' => $height ] );
123 if ( $mto && !$mto->isError() ) {
127 $url = [ $mto->getUrl(), $height === -1 ? 301 : 302 ];
131 return Status::newGood(
$url );
142 if ( !ctype_digit( $oldid ) ) {
143 return Status::newFatal(
'redirect-not-numeric' );
145 $oldid = (int)$oldid;
146 if ( $oldid === 0 ) {
147 return Status::newFatal(
'redirect-not-exists' );
162 if ( !ctype_digit( $curid ) ) {
163 return Status::newFatal(
'redirect-not-numeric' );
165 $curid = (int)$curid;
166 if ( $curid === 0 ) {
167 return Status::newFatal(
'redirect-not-exists' );
184 if ( !ctype_digit( $logid ) ) {
185 return Status::newFatal(
'redirect-not-numeric' );
187 $logid = (int)$logid;
188 if ( $logid === 0 ) {
189 return Status::newFatal(
'redirect-not-exists' );
191 $query = [
'title' =>
'Special:Log',
'logid' => $logid ];
203 private function dispatch() {
205 $status = match ( $this->mType ) {
213 if ( $status && $status->isGood() ) {
216 $value = $status->getValue();
217 if ( is_array( $value ) ) {
218 [
$url, $code ] = $value;
223 if ( $code === 301 ) {
224 $this->
getOutput()->setCdnMaxage( 60 * 60 );
232 if ( $this->mValue !==
null ) {
233 $this->
getOutput()->setStatusCode( 404 );
247 'label-message' =>
'redirect-lookup',
248 'options-messages' => [
249 'redirect-user' =>
'user',
250 'redirect-page' =>
'page',
251 'redirect-revision' =>
'revision',
252 'redirect-file' =>
'file',
253 'redirect-logid' =>
'logid',
259 'label-message' =>
'redirect-value',
268 if ( !empty( $data[
'type'] ) && !empty( $data[
'value'] ) ) {
269 $this->
setParameter( $data[
'type'] .
'/' . $data[
'value'] );
273 return $this->dispatch();
322class_alias( SpecialRedirect::class,
'SpecialRedirect' );
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfScript( $script='index')
Get the URL path to a MediaWiki entry point.
Special page which uses an HTMLForm to handle processing.
getRequest()
Get the WebRequest being used for this instance.
getOutput()
Get the OutputPage being used for this instance.