Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/193506

Change subject: Avoid access to array key that does not exist
......................................................................

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
---
M includes/Import.php
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/06/193506/1

diff --git a/includes/Import.php b/includes/Import.php
index eb2ca77..ac9d016 100644
--- a/includes/Import.php
+++ b/includes/Import.php
@@ -376,12 +376,12 @@
                $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 @@
        /**
         * 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 );
@@ -1617,8 +1618,8 @@
                $dbw = wfGetDB( DB_MASTER );
                # @todo FIXME: This will not record autoblocks
                if ( !$this->getTitle() ) {
-                       wfDebug( __METHOD__ . ": skipping invalid 
{$this->type}/{$this->action} log time, timestamp " .
-                               $this->timestamp . "\n" );
+                       wfDebug( __METHOD__ . ": skipping invalid 
{$this->type}/{$this->action} log time,"
+                               . "timestamp {$this->timestamp} \n" );
                        return;
                }
                # Check if it exists already

-- 
To view, visit https://gerrit.wikimedia.org/r/193506
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I468a95851e6acdb8186a06b0a2ac73499cc4611f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to