Skip to content

Commit

Permalink
Record: type cast page_namespace into int
Browse files Browse the repository at this point in the history
The version and/or configuration of the MySQL client can apparently mean
we get a string instead of an integer, causing the page titles to be
displayed incorrectly.

For good measure, we type cast all getters that should return an int.
  • Loading branch information
MusikAnimal committed Jul 25, 2023
1 parent 1ffdab1 commit 604a310
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Model/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function __construct(
/**
* Get the submission ID.
*
* @return int
* @return string UUID or stringified integer for older submissions.
*/
public function getSubmissionId(): int {
return $this->data['submission_id'];
public function getSubmissionId(): string {
return (string)$this->data['submission_id'];
}

/**
Expand All @@ -76,7 +76,7 @@ public function getSources(): array {
* @return string
*/
public function getPageTitle( bool $underscored = false ): string {
$nsName = $this->data['page_namespace'] === WikiRepository::NS_ID_DRAFTS ? 'Draft:' : '';
$nsName = (int)$this->data['page_namespace'] === WikiRepository::NS_ID_DRAFTS ? 'Draft:' : '';
$pageTitle = $nsName . $this->data['page_title'];
if ( !$underscored ) {
// Remove underscores for display purposes.
Expand Down Expand Up @@ -157,7 +157,7 @@ public function getOresScore(): ?float {
* @return int
*/
public function getRevId(): int {
return $this->data['rev_id'];
return (int)$this->data['rev_id'];
}

/**
Expand All @@ -166,7 +166,7 @@ public function getRevId(): int {
* @return int
*/
public function getRevParentId(): int {
return $this->data['rev_parent_id'];
return (int)$this->data['rev_parent_id'];
}

/** EDITOR / USER */
Expand Down Expand Up @@ -242,7 +242,7 @@ public function getUserContribsUrl(): string {
* @return int On the CopyPatrolRepository::STATUS_ constants.
*/
public function getStatus(): int {
return $this->data['status'];
return (int)$this->data['status'];
}

/**
Expand Down

0 comments on commit 604a310

Please sign in to comment.