- // if we have a Title object, override mPage. Useful for testing and convenience.
- if ( isset( $row['title'] ) ) {
- $this->mTitle = $row['title'];
- $this->mPage = $this->mTitle->getArticleID();
- } else {
- $this->mTitle = null; // Load on demand if needed
+ // If we have a Title object, make sure it is consistent with mPage.
+ if ( $this->mTitle && $this->mTitle->exists() ) {
+ if ( $this->mPage === null ) {
+ // if the page ID wasn't known, set it now
+ $this->mPage = $this->mTitle->getArticleID();
+ } elseif ( $this->mTitle->getArticleID() !== $this->mPage ) {
+ // Got different page IDs. This may be legit (e.g. during undeletion),
+ // but it seems worth mentioning it in the log.
+ wfDebug( "Page ID " . $this->mPage . " mismatches the ID "
+ . $this->mTitle->getArticleID() . " provided by the Title object." );
+ }