getWikiId() ) { $expected = $this->wikiIdToString( $wikiId ); $actual = $this->wikiIdToString( $this->getWikiId() ); throw new PreconditionException( "Expected " . __CLASS__ . " to belong to $expected, but it belongs to $actual" ); } } /** * Emits a deprecation warning $since version if $wikiId is not the same as this wiki. * * @param string|false $wikiId * @param string $since */ protected function deprecateInvalidCrossWiki( $wikiId, string $since ) { if ( $wikiId !== $this->getWikiId() ) { $expected = $this->wikiIdToString( $wikiId ); $actual = $this->wikiIdToString( $this->getWikiId() ); wfDeprecatedMsg( 'Deprecated cross-wiki access to ' . __CLASS__ . '. ' . "Expected: {$expected}, Actual: {$actual}. " . "Pass expected \$wikiId.", $since ); } } /** * Asserts correct $wikiId parameter was passed. * * @param string|false $wikiId */ protected function assertWikiIdParam( $wikiId ) { Assert::parameterType( [ 'string', 'false' ], $wikiId, '$wikiId' ); } /** * Convert $wikiId to a string for logging. * * @param string|false $wikiId * @return string */ private function wikiIdToString( $wikiId ): string { return $wikiId === WikiAwareEntity::LOCAL ? 'the local wiki' : "'{$wikiId}'"; } }