Esempio n. 1
0
    protected function set_up_forums()
    {
        static $forums;
        if (empty($forums)) {
            $this->create_forum('Parent with two flat children');
            $this->create_forum('Flat child #1', 1);
            $this->create_forum('Flat child #2', 1);
            $this->create_forum('Parent with two nested children');
            $this->create_forum('Nested child #1', 4);
            $this->create_forum('Nested child #2', 5);
            $this->create_forum('Parent with flat and nested children');
            $this->create_forum('Mixed child #1', 7);
            $this->create_forum('Mixed child #2', 7);
            $this->create_forum('Nested child #1 of Mixed child #2', 9);
            $this->create_forum('Mixed child #3', 7);
            // Updating forum_parents column here so it's not empty
            // This is required, so we can see whether the methods
            // correctly clear the values.
            $sql = "UPDATE phpbb_forums\n\t\t\t\tSET forum_parents = 'a:0:{}'";
            $this->db->sql_query($sql);
            // Copy the forums into a static array, so we can reuse the list later
            $sql = 'SELECT *
				FROM phpbb_forums';
            $result = $this->db->sql_query($sql);
            $forums = $this->db->sql_fetchrowset($result);
            $this->db->sql_freeresult($result);
        } else {
            $buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums');
            $buffer->insert_all($forums);
            $buffer->flush();
            $this->database_synchronisation(array('phpbb_forums' => array('forum_id')));
        }
    }