Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call WebRequest::getLimitOffset in 1.35 #4575

Merged
merged 8 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion includes/specials/SpecialProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ protected function getGroupName() {
}

private function getLimitOffset() {
return $this->getRequest()->getLimitOffset();
$request = $this->getRequest();
if ( method_exists( $request, 'getLimitOffsetForUser' ) ) {
// MW 1.35+
return $request->getLimitOffsetForUser( $this->getUser() );
} else {
return $request->getLimitOffset();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write this without the else part:

		if ( method_exists( $request, 'getLimitOffsetForUser' ) ) {
			// MW 1.35+
			return $request->getLimitOffsetForUser( $this->getUser() );
		}

		return $request->getLimitOffset();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but I was using the same code block that I was using elsewhere where it wasn't returning, but rather setting a variable, so I kept the else block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is part of the reason why using a guard clause (the form in my variation) is nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

}
8 changes: 7 additions & 1 deletion includes/specials/SpecialUnusedProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ protected function getGroupName() {
}

private function getLimitOffset() {
return $this->getRequest()->getLimitOffset();
$request = $this->getRequest();
if ( method_exists( $request, 'getLimitOffsetForUser' ) ) {
// MW 1.35+
return $request->getLimitOffsetForUser( $this->getUser() );
} else {
return $request->getLimitOffset();
}
}

}
8 changes: 7 additions & 1 deletion includes/specials/SpecialWantedProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ protected function getGroupName() {
}

private function getLimitOffset() {
return $this->getRequest()->getLimitOffset();
$request = $this->getRequest();
if ( method_exists( $request, 'getLimitOffsetForUser' ) ) {
// MW 1.35+
return $request->getLimitOffsetForUser( $this->getUser() );
} else {
return $request->getLimitOffset();
}
}

}
8 changes: 7 additions & 1 deletion src/MediaWiki/Specials/SpecialSearchByProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ public function execute( $query ) {
}

private function getLimitOffset() {
return $this->getRequest()->getLimitOffset();
$request = $this->getRequest();
if ( method_exists( $request, 'getLimitOffsetForUser' ) ) {
// MW 1.35+
return $request->getLimitOffsetForUser( $this->getUser() );
} else {
return $request->getLimitOffset();
}
}

/**
Expand Down