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

user_notifications_table_remove_duplicates.php

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


01  <?php
02  /**
03   *
04   * This file is part of the phpBB Forum Software package.
05   *
06   * @copyright (c) phpBB Limited <https://www.phpbb.com>
07   * @license GNU General Public License, version 2 (GPL-2.0)
08   *
09   * For full copyright and license information, please see
10   * the docs/CREDITS.txt file.
11   *
12   */
13   
14  namespace phpbb\db\migration\data\v32x;
15   
16  class user_notifications_table_remove_duplicates extends \phpbb\db\migration\migration
17  {
18      static public function depends_on()
19      {
20          return array(
21              '\phpbb\db\migration\data\v32x\user_notifications_table_temp_index',
22          );
23      }
24   
25      public function update_data()
26      {
27          return array(
28              array('custom', array(array($this, 'remove_duplicates'))),
29          );
30      }
31   
32      public function remove_duplicates()
33      {
34          $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications');
35   
36          $sql = "SELECT item_type, item_id, user_id, method, MAX(notify) AS notify
37                  FROM {$this->table_prefix}user_notifications
38                  GROUP BY item_type, item_id, user_id, method
39                  HAVING COUNT(item_type) > 1";
40   
41          $result = $this->sql_query($sql);
42          while ($row = $this->db->sql_fetchrow($result))
43          {
44              // Delete the duplicate entries
45              $this->sql_query("DELETE FROM {$this->table_prefix}user_notifications
46                                  WHERE user_id = {$row['user_id']}
47                                    AND item_type = '{$row['item_type']}'
48                                    AND method = '{$row['method']}'");
49   
50              // And re-insert as a single one
51              $insert_buffer->insert($row);
52          }
53          $this->db->sql_freeresult($result);
54      }
55  }
56