Fix Undefined variable issue in ApiQueryUserContributions
authorSébastien Santoro <dereckson@espace-win.org>
Thu, 28 Jul 2016 00:17:33 +0000 (00:17 +0000)
committerSébastien Santoro <dereckson@espace-win.org>
Thu, 28 Jul 2016 00:17:33 +0000 (00:17 +0000)
Some ApiQueryUserContributions::prepareQuery code paths don't define
the $index array, but try to use it anyway.

That raises the following notice:
     Undefined variable: index
     in …/includes/api/ApiQueryUserContributions.php on line 340

This commit ensures we only try to use the variable when needed.

Bug: T141497
Change-Id: Ib9c038b84219bc1886139cb079a33aba74bc5220

includes/api/ApiQueryUserContributions.php

index 60e91e8..51e1923 100644 (file)
@@ -337,7 +337,9 @@ class ApiQueryContributions extends ApiQueryBase {
                        $this->addWhereFld( 'ct_tag', $this->params['tag'] );
                }
 
-               $this->addOption( 'USE INDEX', $index );
+               if ( isset( $index ) ) {
+                       $this->addOption( 'USE INDEX', $index );
+               }
        }
 
        /**