Skip to content

Commit

Permalink
Do not crash if addwiki/mediawiki-api-base is missing
Browse files Browse the repository at this point in the history
Instead of crashing with a fatal error and a stack trace, check if one of the
classes that we need is available, using that class as a proxy for the overall
package. If not, uses of the parser function return a nice error message but
the parsing does not fail and the rest of the page can be shown.

WIK-1250
  • Loading branch information
DanielWTQ committed Jan 22, 2024
1 parent ef2fe13 commit 2f3ebb2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/RemoteWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public function __construct(
* @return string
*/
public function remoteVersion( Parser $parser, $endPoint = null, $type = null ): string {
// Verify that the `addwiki/mediawiki-api-base` composer dependency is
// installed - we check if the `Addwiki\Mediawiki\Api\Client\MediaWiki`
// class is installed and assume that if it is, the entire package is
// available.
if ( !class_exists( MediaWiki::class ) ) {
return '(RemoteWiki: addwiki/mediawiki-api-base not installed)';
}

if ( !$this->validateEndpoint( $endPoint ) ) {
return '';
}
Expand Down

0 comments on commit 2f3ebb2

Please sign in to comment.