From: physikerwelt Date: Fri, 27 Feb 2015 21:53:56 +0000 (-0500) Subject: Avoid access to array key that does not exist X-Git-Tag: 1.31.0-rc.0~12244 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=0a6912f20f1b509efb333c6c3d67258a0389a483;p=lhc%2Fweb%2Fwiklou.git Avoid access to array key that does not exist Accessing an array element that is not set causes a PHP notice. This change first, checks if the array key is present. Bug: T91127 Change-Id: I468a95851e6acdb8186a06b0a2ac73499cc4611f --- diff --git a/includes/Import.php b/includes/Import.php index eb2ca778fe..c036fbecf1 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -376,12 +376,12 @@ class WikiImporter { $page->loadPageData( 'fromdbmaster' ); $content = $page->getContent(); $editInfo = $page->prepareContentForEdit( $content ); - + $countKey = 'title_' . $title->getPrefixedText(); $countable = $page->isCountable( $editInfo ); - $oldcountable = $this->countableCache['title_' . $title->getPrefixedText()]; - if ( isset( $oldcountable ) && $countable != $oldcountable ) { + if ( array_key_exists( $countKey, $this->countableCache ) && + $countable != $this->countableCache[ $countKey ] ) { DeferredUpdates::addUpdate( SiteStatsUpdate::factory( array( - 'articles' => ( (int)$countable - (int)$oldcountable ) + 'articles' => ( (int)$countable - (int)$this->countableCache[ $countKey ] ) ) ) ); } @@ -477,7 +477,8 @@ class WikiImporter { /** * Retrieves the contents of the named attribute of the current element. * @param string $attr The name of the attribute - * @return string The value of the attribute or an empty string if it is not set in the current element. + * @return string The value of the attribute or an empty string if it is not set in the current + * element. */ public function nodeAttribute( $attr ) { return $this->reader->getAttribute( $attr );