Skip to content

Commit bc7efea

Browse files
authored
Merge pull request #258 from iMattPro/updates
Little fixes
2 parents 0af2404 + 6ae6ce5 commit bc7efea

File tree

3 files changed

+472
-350
lines changed

3 files changed

+472
-350
lines changed

includes/qi_populate.php

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class qi_populate
3232
private $post_chunks = 0;
3333
private $topic_chunks = 0;
3434

35-
/**
36-
* Lorem ipsum, a placeholder for the posts.
37-
*/
38-
private $lorem_ipsum = '';
39-
4035
/**
4136
* $user_arr = array(
4237
* (int) $user_id => array(
@@ -67,16 +62,6 @@ class qi_populate
6762
*/
6863
private $forum_arr = array();
6964

70-
/**
71-
* $topc_arr = array(
72-
* (int) $topic_id => array(
73-
* 'topic_id' => (int) $topic_id,
74-
* 'forum_id' => (int) $forum_id,
75-
* ),
76-
* );
77-
*/
78-
private $topc_arr = array();
79-
8065
// The default forums. To copy permissions from.
8166
private $def_cat_id = 0;
8267
private $def_forum_id = 0;
@@ -157,7 +142,7 @@ public function run()
157142

158143
if ($this->num_users)
159144
{
160-
// If we have users we also need a e-mail domain.
145+
// If we have users we also need an e-mail domain.
161146
$this->email_domain = trim($settings->get_config('email_domain', ''));
162147

163148
if (empty($this->email_domain))
@@ -207,11 +192,11 @@ public function run()
207192
}
208193

209194
/**
210-
* Make the first two users a admin and a global moderator.
195+
* Make the first two users an admin and a global moderator.
211196
*/
212197
private function create_management()
213198
{
214-
global $db, $phpbb_root_path, $phpEx, $settings;
199+
global $phpbb_root_path, $phpEx, $settings;
215200

216201
// Don't do anything if there is not enough users.
217202
$users_needed = 0;
@@ -226,8 +211,10 @@ private function create_management()
226211
// Get group id for admins and moderators.
227212
$user_groups = $this->get_groups();
228213
$admin_group = (int) array_search('ADMINISTRATORS', $user_groups, true);
229-
$mod_group = (int) array_search('GLOBAL_MODERATORS', $user_groups, true);;
214+
$mod_group = (int) array_search('GLOBAL_MODERATORS', $user_groups, true);
230215

216+
// Load language file array
217+
$lang = [];
231218
if (file_exists("{$phpbb_root_path}language/" . $settings->get_config('default_lang') . "/common.$phpEx"))
232219
{
233220
include("{$phpbb_root_path}language/" . $settings->get_config('default_lang') . "/common.$phpEx");
@@ -261,6 +248,8 @@ private function create_management()
261248
group_user_add($mod_group, $user['user_id'], false, $lang['G_GLOBAL_MODERATORS'], true, 1);
262249
}
263250
}
251+
252+
unset($lang); // Free memory
264253
}
265254

266255
/**
@@ -282,7 +271,7 @@ private function fill_forums()
282271
$post_id = (int) $row['post_id'];
283272
$db->sql_freeresult($result);
284273

285-
// Put topics and posts in their arrays so they can be sent to the database when the limit is reached.
274+
// Put topics and posts in their arrays, so they can be sent to the database when the limit is reached.
286275
$sql_topics = $sql_posts = array();
287276

288277
// Use the default user if no new users are being populated
@@ -317,11 +306,11 @@ private function fill_forums()
317306

318307
for ($i = 0; $i < $topics; $i++)
319308
{
320-
// Increase this here so we get the number for the topic title.
309+
// Increase this here, so we get the number for the topic title.
321310
$topic_cnt++;
322311

323312
$topic_arr = array(
324-
'topic_id' => (int) ++$topic_id,
313+
'topic_id' => ++$topic_id,
325314
'forum_id' => (int) $forum['forum_id'],
326315
'topic_title' => qi::lang('TEST_TOPIC_TITLE', $topic_cnt),
327316
);
@@ -380,7 +369,7 @@ private function fill_forums()
380369
$sql_posts[count($sql_posts) - 1]['post_visibility'] = ITEM_APPROVED;
381370
}
382371

383-
if ($j == 0)
372+
if ($j === 0)
384373
{
385374
// Put some first post info to the topic array.
386375
$topic_arr['topic_first_post_id'] = $post_id;
@@ -466,6 +455,8 @@ private function fill_forums()
466455
$db->sql_query($sql);
467456
}
468457

458+
unset($forum);
459+
469460
if (count($sql_posts))
470461
{
471462
// Save the array to the posts table
@@ -519,7 +510,7 @@ private function create_forums()
519510

520511
for ($i = 0; $i < $this->num_cats; $i++)
521512
{
522-
// Create catergories and fill a array with parent ids.
513+
// Create categories and fill an array with parent ids.
523514
$parent_arr[] = $this->_create_forums(FORUM_CAT, $i + 1, $acp_forums);
524515
}
525516

@@ -657,7 +648,7 @@ private function save_users()
657648
$registered_group = (int) array_search('REGISTERED', $user_groups, true);
658649
$newly_registered_group = (int) array_search('NEWLY_REGISTERED', $user_groups, true);
659650

660-
$s_chunks = ($this->num_users > $this->user_chunks) ? true : false;
651+
$s_chunks = $this->num_users > $this->user_chunks;
661652
$end = $this->num_users + 1;
662653
$chunk_cnt = 0;
663654
$sql_ary = array();

0 commit comments

Comments
 (0)