@@ -200,12 +200,17 @@ private function makeMessages ()
200200 'approved ' => TRUE
201201 );
202202
203+ $ makenew = ($ this ->counters ['topics ' ]['current ' ] < $ this ->counters ['topics ' ]['max ' ]) && (mt_rand () < (int )(mt_getrandmax () * ($ this ->counters ['topics ' ]['max ' ] / $ this ->counters ['messages ' ]['max ' ])));
204+
203205 $ topicOptions = array (
204- 'id ' => $ this -> counters [ ' topics ' ][ ' current ' ] < $ this -> counters [ ' topics ' ][ ' max ' ] && mt_rand () < ( int )( mt_getrandmax () * ( $ this -> counters [ ' topics ' ][ ' max ' ] / $ this -> counters [ ' messages ' ][ ' max ' ])) ? 0 : ( $ this -> counters [ ' topics ' ][ ' current ' ] < $ this -> counters [ ' topics ' ][ ' max ' ] ? mt_rand (1 , ++ $ this ->counters ['topics ' ]['current ' ]) : mt_rand ( 1 , $ this -> counters [ ' topics ' ][ ' current ' ]) ),
206+ 'id ' => $ makenew ? 0 : mt_rand (1 , $ this ->counters ['topics ' ]['current ' ]),
205207 'board ' => mt_rand (1 , $ this ->counters ['boards ' ]['max ' ]),
206208 'mark_as_read ' => TRUE ,
207209 );
208210
211+ if ($ makenew )
212+ $ this ->counters ['topics ' ]['current ' ]++;
213+
209214 $ member = mt_rand (1 , $ this ->counters ['members ' ]['max ' ]);
210215 $ posterOptions = array (
211216 'id ' => $ member ,
@@ -248,14 +253,28 @@ private function pause ($end = false)
248253
249254 private function fixupTopicsBoards ()
250255 {
251- global $ smcFunc , $ sourcedir ;
252-
253- $ smcFunc ['db_query ' ]('' , '
254- UPDATE {db_prefix}messages as mes, {db_prefix}topics as top
255- SET mes.id_board = top.id_board
256- WHERE mes.id_topic = top.id_topic ' ,
257- array ()
258- );
256+ global $ smcFunc , $ sourcedir , $ db_type ;
257+
258+ // No $smcFunc exists for this, so we will brute force it...
259+ if ($ db_type == 'postgresql ' )
260+ {
261+ $ smcFunc ['db_query ' ]('' , '
262+ UPDATE {db_prefix}messages
263+ SET id_board = {db_prefix}topics.id_board
264+ FROM {db_prefix}topics
265+ WHERE {db_prefix}messages.id_topic = {db_prefix}topics.id_topic ' ,
266+ array ()
267+ );
268+ }
269+ else
270+ {
271+ $ smcFunc ['db_query ' ]('' , '
272+ UPDATE {db_prefix}messages as mes, {db_prefix}topics as top
273+ SET mes.id_board = top.id_board
274+ WHERE mes.id_topic = top.id_topic ' ,
275+ array ()
276+ );
277+ }
259278 }
260279
261280 private function complete ($ end )
0 commit comments