Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -141,6 +141,19 @@ |
142 | 142 | } |
143 | 143 | return true; |
144 | 144 | } |
| 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 | + } |
145 | 158 | |
146 | 159 | public function save() { |
147 | 160 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -183,7 +196,7 @@ |
184 | 197 | 'cp_path' => $path['path'], |
185 | 198 | 'cp_action' => $path['action'] ); |
186 | 199 | } |
187 | | - $dbw->insert( 'code_paths', $data, __METHOD__, array( 'IGNORE' ) ); |
| 200 | + $this->insertChunks( $dbw, 'code_paths', $data, __METHOD__, array( 'IGNORE' ) ); |
188 | 201 | } |
189 | 202 | // Update bug references table... |
190 | 203 | $affectedBugs = array(); |