[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\db\migration\data\v30x; 15 16 class release_3_0_11_rc1 extends \phpbb\db\migration\migration 17 { 18 public function effectively_installed() 19 { 20 return phpbb_version_compare($this->config['version'], '3.0.11-RC1', '>='); 21 } 22 23 static public function depends_on() 24 { 25 return array('\phpbb\db\migration\data\v30x\release_3_0_10'); 26 } 27 28 public function update_data() 29 { 30 return array( 31 array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), 32 array('custom', array(array(&$this, 'delete_orphan_private_messages'))), 33 34 array('config.update', array('version', '3.0.11-RC1')), 35 ); 36 } 37 38 public function cleanup_deactivated_styles() 39 { 40 // Updates users having current style a deactivated one 41 $sql = 'SELECT style_id 42 FROM ' . STYLES_TABLE . ' 43 WHERE style_active = 0'; 44 $result = $this->sql_query($sql); 45 46 $deactivated_style_ids = array(); 47 while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) 48 { 49 $deactivated_style_ids[] = (int) $style_id; 50 } 51 $this->db->sql_freeresult($result); 52 53 if (!empty($deactivated_style_ids)) 54 { 55 $sql = 'UPDATE ' . USERS_TABLE . ' 56 SET user_style = ' . (int) $this->config['default_style'] .' 57 WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); 58 $this->sql_query($sql); 59 } 60 } 61 62 public function delete_orphan_private_messages() 63 { 64 // Delete orphan private messages 65 $batch_size = 500; 66 67 $sql_array = array( 68 'SELECT' => 'p.msg_id', 69 'FROM' => array( 70 PRIVMSGS_TABLE => 'p', 71 ), 72 'LEFT_JOIN' => array( 73 array( 74 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), 75 'ON' => 'p.msg_id = t.msg_id', 76 ), 77 ), 78 'WHERE' => 't.user_id IS NULL', 79 ); 80 $sql = $this->db->sql_build_query('SELECT', $sql_array); 81 82 $result = $this->db->sql_query_limit($sql, $batch_size); 83 84 $delete_pms = array(); 85 while ($row = $this->db->sql_fetchrow($result)) 86 { 87 $delete_pms[] = (int) $row['msg_id']; 88 } 89 $this->db->sql_freeresult($result); 90 91 if (!empty($delete_pms)) 92 { 93 $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' 94 WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); 95 $this->sql_query($sql); 96 97 // Return false to have the Migrator call this function again 98 return false; 99 } 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |