Skip to content

Commit 63ea0de

Browse files
committed
Add copying webpush subscriptions data to phpBB 4.0 tables if exist.
1 parent 27c4f2c commit 63ea0de

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

migrations/handle_subscriptions.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function revert_data(): array
1818
{
1919
return [
2020
['custom', [[$this, 'update_subscriptions']]],
21+
['if', [
22+
($this->container->has('notification.method.webpush')),
23+
['custom', [[$this, 'copy_subscription_tables']]],
24+
]],
2125
];
2226
}
2327

@@ -43,4 +47,27 @@ public function update_subscriptions()
4347

4448
$this->db->sql_query($sql);
4549
}
50+
51+
public function copy_subscription_tables()
52+
{
53+
$core_notification_push_table = $this->table_prefix . 'notification_push';
54+
$core_push_subscriptions_table = $this->table_prefix . 'push_subscriptions';
55+
56+
$wpn_notification_push_table = $this->table_prefix . 'wpn_notification_push';
57+
$wpn_push_subscriptions_table = $this->table_prefix . 'wpn_push_subscriptions';
58+
59+
/*
60+
* If webpush notification method exists in phpBB core,
61+
* copy all subscriptions data over the corresponding core tables.
62+
*/
63+
foreach ([
64+
$core_notification_push_table => $wpn_notification_push_table,
65+
$core_push_subscriptions_table => $wpn_push_subscriptions_table
66+
] as $core_table => $ext_table)
67+
{
68+
$sql = 'INSERT INTO ' . $core_table . '
69+
SELECT * FROM ' . $ext_table;
70+
$this->db->sql_query($sql);
71+
}
72+
}
4673
}

0 commit comments

Comments
 (0)