Repository navigation
Replace deprecated InterwikiLoadPrefix hook with InterwikiLookup serv… #51
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule build
updated
9 files
| +4 −1 | .gitignore | |
| +79 −18 | Dockerfile | |
| +58 −10 | Makefile | |
| +93 −111 | README.adoc | |
| +2 −2 | docker-compose-dev.yml | |
| +4 −2 | docker-compose.override.yml.SAMPLE | |
| +10 −0 | docker-compose.yml | |
| +378 −0 | docs/use-case-github-actions.adoc | |
| +640 −0 | docs/use-case-local-development.adoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <?php | ||
|
|
||
| namespace SEQL; | ||
|
|
||
| use Interwiki; | ||
| use MediaWiki\Interwiki\InterwikiLookup; | ||
| use MediaWiki\Language\Language; | ||
|
|
||
| /** | ||
| * InterwikiLookup decorator to expose endpoints configured in | ||
| * $seqlgExternalRepositoryEndpoints as interwiki prefixes without having | ||
| * to create an interwiki table entry. | ||
| * | ||
| * Prefixes found in the external repository endpoints setting take precedence | ||
| * over those found in the `interwiki` table, any other prefix is delegated to | ||
| * the decorated InterwikiLookup. | ||
| * | ||
| * Prefix matching follows `ClassicInterwikiLookup` and is case-insensitive, | ||
| * with the prefix being resolved against the content language. | ||
| * | ||
| * @license GPL-2.0-or-later | ||
| * @since 2.0.1 | ||
| */ | ||
| class InterwikiLookupDecorator implements InterwikiLookup { | ||
|
|
||
| /** | ||
| * @var InterwikiLookup | ||
| */ | ||
| private $interwikiLookup; | ||
|
|
||
| /** | ||
| * @var DynamicInterwikiPrefixLoader | ||
| */ | ||
| private $dynamicInterwikiPrefixLoader; | ||
|
|
||
| /** | ||
| * @var Language | ||
| */ | ||
| private $contentLanguage; | ||
|
|
||
| /** | ||
| * @since 2.0.1 | ||
| * | ||
| * @param InterwikiLookup $interwikiLookup | ||
| * @param DynamicInterwikiPrefixLoader $dynamicInterwikiPrefixLoader | ||
| * @param Language $contentLanguage | ||
| */ | ||
| public function __construct( InterwikiLookup $interwikiLookup, DynamicInterwikiPrefixLoader $dynamicInterwikiPrefixLoader, Language $contentLanguage ) { | ||
| $this->interwikiLookup = $interwikiLookup; | ||
| $this->dynamicInterwikiPrefixLoader = $dynamicInterwikiPrefixLoader; | ||
| $this->contentLanguage = $contentLanguage; | ||
| } | ||
|
|
||
| /** | ||
| * @since 2.0.1 | ||
| * | ||
| * @param string|null $prefix | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function isValidInterwiki( $prefix ) { | ||
| // Guarded like `ClassicInterwikiLookup` so that neither the content | ||
| // language nor the prefix loader are consulted with `null` or an | ||
| // empty prefix | ||
| if ( $prefix === null || $prefix === '' ) { | ||
| return $this->interwikiLookup->isValidInterwiki( $prefix ); | ||
| } | ||
|
|
||
| if ( $this->dynamicInterwikiPrefixLoader->isEnabledPrefixForExternalRepository( $this->contentLanguage->lc( $prefix ) ) ) { | ||
| return true; | ||
| } | ||
|
|
||
| return $this->interwikiLookup->isValidInterwiki( $prefix ); | ||
| } | ||
|
|
||
| /** | ||
| * @since 2.0.1 | ||
| * | ||
| * @param string|null $prefix | ||
| * | ||
| * @return Interwiki|null|false | ||
| */ | ||
| public function fetch( $prefix ) { | ||
| if ( $prefix !== null && $prefix !== '' ) { | ||
| $interwiki = $this->dynamicInterwikiPrefixLoader->newInterwiki( $this->contentLanguage->lc( $prefix ) ); | ||
|
|
||
| if ( $interwiki !== null ) { | ||
| return $interwiki; | ||
| } | ||
| } | ||
|
|
||
| return $this->interwikiLookup->fetch( $prefix ); | ||
| } | ||
|
|
||
| /** | ||
| * @since 2.0.1 | ||
| * | ||
| * @param bool|null $local | ||
| * | ||
| * @return array[] | ||
| */ | ||
| public function getAllPrefixes( $local = null ) { | ||
| return $this->interwikiLookup->getAllPrefixes( $local ); | ||
| } | ||
|
|
||
| /** | ||
| * @since 2.0.1 | ||
| * | ||
| * @param string $prefix | ||
| */ | ||
| public function invalidateCache( $prefix ) { | ||
| $this->interwikiLookup->invalidateCache( $prefix ); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.