diff --git a/includes/API/GetHashChainInfoHandler.php b/includes/API/GetHashChainInfoHandler.php index e9ab5683..113a60a7 100644 --- a/includes/API/GetHashChainInfoHandler.php +++ b/includes/API/GetHashChainInfoHandler.php @@ -59,15 +59,13 @@ public function getParamSettings() { */ protected function getEntity( string $identifierType ): ?VerificationEntity { $identifier = $this->getValidatedParams()['identifier']; - $conds = []; if ( $identifierType === 'title' ) { - // TODO: DB data should hold Db key, not prefixed text (spaces replaced with _) - // Once that is done, remove next line - $identifier = str_replace( '_', ' ', $identifier ); - $conds['page_title'] = $identifier; + $title = \Title::newFromText( $identifier ); + return $this->verificationEngine->getLookup()->verificationEntityFromTitle( $title ); } else { - $conds[VerificationEntity::GENESIS_HASH] = $identifier; + return $this->verificationEngine->getLookup()->verificationEntityFromQuery( [ + VerificationEntity::GENESIS_HASH => $identifier, + ] ); } - return $this->verificationEngine->getLookup()->verificationEntityFromQuery( $conds ); } } diff --git a/includes/API/GetPageAllRevsHandler.php b/includes/API/GetPageAllRevsHandler.php index 8504fb39..854cfdbc 100644 --- a/includes/API/GetPageAllRevsHandler.php +++ b/includes/API/GetPageAllRevsHandler.php @@ -38,11 +38,7 @@ public function getParamSettings() { * @return VerificationEntity|null */ protected function getEntity( string $pageTitle ): ?VerificationEntity { - // TODO: DB data should hold Db key, not prefixed text (spaces replaced with _) - // Once that is done, remove next line - $pageTitle = str_replace( '_', ' ', $pageTitle ); - return $this->verificationEngine->getLookup()->verificationEntityFromQuery( [ - 'page_title' => $pageTitle - ] ); + $title = \Title::newFromText( $pageTitle ); + return $this->verificationEngine->getLookup()->verificationEntityFromTitle( $title ); } } diff --git a/includes/API/GetPageLastRevHandler.php b/includes/API/GetPageLastRevHandler.php index 2feef950..4d6e1296 100644 --- a/includes/API/GetPageLastRevHandler.php +++ b/includes/API/GetPageLastRevHandler.php @@ -35,12 +35,7 @@ public function getParamSettings() { * @return VerificationEntity|null */ protected function getEntity(): ?VerificationEntity { - $pageTitle = $this->getValidatedParams()['page_title']; - // TODO: DB data should hold Db key, not prefixed text (spaces replaced with _) - // Once that is done, remove next line - $pageTitle = str_replace( '_', ' ', $pageTitle ); - return $this->verificationEngine->getLookup()->verificationEntityFromQuery( [ - 'page_title' => $pageTitle - ] ); + $title = \Title::newFromText( $this->getValidatedParams()['page_title'] ); + return $this->verificationEngine->getLookup()->verificationEntityFromTitle( $title ); } } diff --git a/includes/Verification/VerificationLookup.php b/includes/Verification/VerificationLookup.php index 244a9228..f28831b2 100644 --- a/includes/Verification/VerificationLookup.php +++ b/includes/Verification/VerificationLookup.php @@ -62,7 +62,7 @@ public function verificationEntityFromRevId( int $revId ): ?VerificationEntity { * @return VerificationEntity|null */ public function verificationEntityFromTitle( Title $title ): ?VerificationEntity { - if ( !$title->exists() ) { + if ( !( $title instanceof Title ) || !$title->exists() ) { return null; } // TODO: Replace with getPrefixedDBkey, once database enties use it