From 7269b2e2b325577ad1fa6fbd857495ba2ffd5f5f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 21 Aug 2009 18:11:13 +0000 Subject: [PATCH] Fix for wgArticleId being exported to JavaScript as a string instead of integer. :P Throw around some intval()s on page id, length data coming out of database into Title and Article objects and the link cache... blast PHP's soft typing! --- includes/Article.php | 8 ++++---- includes/LinkCache.php | 12 +++++++----- includes/Title.php | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index edd015bebb..75748f8287 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -406,15 +406,15 @@ class Article { if( $data ) { $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect ); - $this->mTitle->mArticleID = $data->page_id; + $this->mTitle->mArticleID = intval( $data->page_id ); # Old-fashioned restrictions $this->mTitle->loadRestrictions( $data->page_restrictions ); - $this->mCounter = $data->page_counter; + $this->mCounter = intval( $data->page_counter ); $this->mTouched = wfTimestamp( TS_MW, $data->page_touched ); - $this->mIsRedirect = $data->page_is_redirect; - $this->mLatest = $data->page_latest; + $this->mIsRedirect = intval( $data->page_is_redirect ); + $this->mLatest = intval( $data->page_latest ); } else { if( is_object( $this->mTitle ) ) { $lc->addBadLinkObj( $this->mTitle ); diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 4f74cdd70f..a6d2185ec6 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -74,8 +74,10 @@ class LinkCache { */ public function addGoodLinkObj( $id, $title, $len = -1, $redir = NULL ) { $dbkey = $title->getPrefixedDbKey(); - $this->mGoodLinks[$dbkey] = $id; - $this->mGoodLinkFields[$dbkey] = array( 'length' => $len, 'redirect' => $redir ); + $this->mGoodLinks[$dbkey] = intval( $id ); + $this->mGoodLinkFields[$dbkey] = array( + 'length' => intval( $len ), + 'redirect' => intval( $redir ) ); } public function addBadLinkObj( $title ) { @@ -167,9 +169,9 @@ class LinkCache { __METHOD__, $options ); # Set fields... if ( $s !== false ) { - $id = $s->page_id; - $len = $s->page_len; - $redirect = $s->page_is_redirect; + $id = intval( $s->page_id ); + $len = intval( $s->page_len ); + $redirect = intval( $s->page_is_redirect ); } else { $len = -1; $redirect = 0; diff --git a/includes/Title.php b/includes/Title.php index 48063be64e..51a9c17ea0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2158,7 +2158,7 @@ class Title { $linkCache->clearBadLink( $this->getPrefixedDBkey() ); if ( $newid === false ) { $this->mArticleID = -1; } - else { $this->mArticleID = $newid; } + else { $this->mArticleID = intval( $newid ); } $this->mRestrictionsLoaded = false; $this->mRestrictions = array(); } -- 2.20.1