aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/site/DBSiteStore.php2
-rw-r--r--includes/site/Site.php12
2 files changed, 10 insertions, 4 deletions
diff --git a/includes/site/DBSiteStore.php b/includes/site/DBSiteStore.php
index b06e794c8486..ee4497789391 100644
--- a/includes/site/DBSiteStore.php
+++ b/includes/site/DBSiteStore.php
@@ -200,7 +200,7 @@ class DBSiteStore implements SiteStore {
'site_source' => $site->getSource(),
'site_language' => $site->getLanguageCode() ?? '',
'site_protocol' => $site->getProtocol(),
- 'site_domain' => strrev( $site->getDomain() ) . '.',
+ 'site_domain' => strrev( $site->getDomain() ?? '' ) . '.',
'site_data' => serialize( $site->getExtraData() ),
// Site config
diff --git a/includes/site/Site.php b/includes/site/Site.php
index e84f1c7ce1ea..f93ed15dd52b 100644
--- a/includes/site/Site.php
+++ b/includes/site/Site.php
@@ -261,20 +261,26 @@ class Site implements Serializable {
/**
* Returns the domain of the site, ie en.wikipedia.org
- * Or false if it's not known.
+ * Or null if it's not known.
*
* @since 1.21
*
* @return string|null
*/
- public function getDomain() {
+ public function getDomain(): ?string {
$path = $this->getLinkPath();
if ( $path === null ) {
return null;
}
- return parse_url( $path, PHP_URL_HOST );
+ $domain = parse_url( $path, PHP_URL_HOST );
+
+ if ( $domain === false ) {
+ $domain = null;
+ }
+
+ return $domain;
}
/**