Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

remove_duplicate_migrations.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.14 KiB


01  <?php
02   
03  /**
04   *
05   * This file is part of the phpBB Forum Software package.
06   *
07   * @copyright (c) phpBB Limited <https://www.phpbb.com>
08   * @license GNU General Public License, version 2 (GPL-2.0)
09   *
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  }
78