[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * 5 * This file is part of the phpBB Forum Software package. 6 * 7 * @copyright (c) phpBB Limited <https://www.phpbb.com> 8 * @license GNU General Public License, version 2 (GPL-2.0) 9 * 10 * For full copyright and license information, please see 11 * the docs/CREDITS.txt file. 12 * 13 */ 14 15 namespace phpbb\db\migration\data\v31x; 16 17 class remove_duplicate_migrations extends \phpbb\db\migration\migration 18 { 19 static public function depends_on() 20 { 21 return array('\phpbb\db\migration\data\v31x\v3110'); 22 } 23 24 public function update_data() 25 { 26 return array( 27 array('custom', array(array($this, 'deduplicate_entries'))), 28 ); 29 } 30 31 public function deduplicate_entries() 32 { 33 $migration_state = array(); 34 $duplicate_migrations = array(); 35 36 $sql = "SELECT * 37 FROM " . $this->table_prefix . 'migrations'; 38 $result = $this->db->sql_query($sql); 39 40 if (!$this->db->get_sql_error_triggered()) 41 { 42 while ($migration = $this->db->sql_fetchrow($result)) 43 { 44 $migration_state[$migration['migration_name']] = $migration; 45 46 $migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); 47 } 48 } 49 50 $this->db->sql_freeresult($result); 51 52 foreach ($migration_state as $name => $migration) 53 { 54 $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name; 55 $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name; 56 57 if ($prepended_name != $name && isset($migration_state[$prepended_name]) && $migration_state[$prepended_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on']) 58 { 59 $duplicate_migrations[] = $name; 60 unset($migration_state[$prepended_name]); 61 } 62 else if ($prefixless_name != $name && isset($migration_state[$prefixless_name]) && $migration_state[$prefixless_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on']) 63 { 64 $duplicate_migrations[] = $prefixless_name; 65 unset($migration_state[$prefixless_name]); 66 } 67 } 68 69 if (count($duplicate_migrations)) 70 { 71 $sql = 'DELETE 72 FROM ' . $this->table_prefix . 'migrations 73 WHERE ' . $this->db->sql_in_set('migration_name', $duplicate_migrations); 74 $this->db->sql_query($sql); 75 } 76 } 77 }
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 |