r101986 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101985‎ | r101986 | r101987 >
Date:12:33, 4 November 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Fix edge case where array_fill() exploded because the array was empty
Modified paths:
  • /branches/RL2/extensions/Gadgets/backend/CachedGadgetRepo.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/backend/CachedGadgetRepo.php
@@ -123,7 +123,12 @@
124124 $this->data = $this->loadAllData();
125125 $arrayKeys = array_keys( $this->data );
126126 // For memc, prepare an array with the IDs as keys but with each value set to null
127 - $toCache = array_combine( $arrayKeys, array_fill( 0, count( $arrayKeys ), null ) );
 127+ if ( count( $arrayKeys ) > 0 ) {
 128+ $toCache = array_combine( $arrayKeys, array_fill( 0, count( $arrayKeys ), null ) );
 129+ } else {
 130+ // array_fill() and array_combine() don't like empty arrays
 131+ $toCache = array();
 132+ }
128133 $wgMemc->set( $key, $toCache );
129134
130135 // Now that we have the data for every gadget, let's refresh those cache entries too

Status & tagging log