r53921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53920‎ | r53921 | r53922 >
Date:01:48, 29 July 2009
Author:brion
Status:ok
Tags:
Comment:
Chunk file list inserts on revision save; giant civicrm vendor branch import overran packet size on my local install :P
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -141,6 +141,19 @@
142142 }
143143 return true;
144144 }
 145+
 146+ /**
 147+ * Quickie protection against huuuuuuuuge batch inserts
 148+ */
 149+ protected function insertChunks( $db, $table, $data, $method, $options=array() ) {
 150+ $chunkSize = 100;
 151+ for( $i = 0; $i < count( $data ); $i += $chunkSize ) {
 152+ $db->insert( 'code_paths',
 153+ array_slice( $data, $i, $chunkSize ),
 154+ __METHOD__,
 155+ array( 'IGNORE' ) );
 156+ }
 157+ }
145158
146159 public function save() {
147160 $dbw = wfGetDB( DB_MASTER );
@@ -183,7 +196,7 @@
184197 'cp_path' => $path['path'],
185198 'cp_action' => $path['action'] );
186199 }
187 - $dbw->insert( 'code_paths', $data, __METHOD__, array( 'IGNORE' ) );
 200+ $this->insertChunks( $dbw, 'code_paths', $data, __METHOD__, array( 'IGNORE' ) );
188201 }
189202 // Update bug references table...
190203 $affectedBugs = array();

Status & tagging log