Skip to content

Commit af7922c

Browse files
boneliferclaude
andauthored
Translate the old-extension message in ext.php (#9)
ext.php refused to enable with a hard-coded English message while the old extension was still enabled. The message now comes from the install language file, as phpBB's validation policy requires. The migration-history move also rewrites other extensions' dependency lists that point at the renamed migrations, not just this extension's own rows. phpBB reads those lists when reverting migrations. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0cc25d9 commit af7922c

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎ext.php‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public function is_enableable()
5252

5353
if ($this->container->get('ext.manager')->is_enabled(self::OLD_EXT_NAME))
5454
{
55-
return ['Disable the old "' . self::OLD_EXT_NAME . '" extension first (keep its data, do not delete it).'];
55+
$language = $this->container->get('language');
56+
$language->add_lang('install_editedpostsunread', 'phpbbmodders/editedpostsunread');
57+
58+
return $language->lang('EDITEDPOSTSUNREAD_DISABLE_OLD', self::OLD_EXT_NAME);
5659
}
5760

5861
return true;
@@ -119,16 +122,20 @@ protected function move_old_install()
119122

120123
foreach ($rows as $row)
121124
{
122-
if ($this->new_class_name($row['migration_name']) === $row['migration_name'])
125+
// Other extensions' migrations may depend on ours, so their
126+
// dependency lists are rewritten too, not just our own rows
127+
$old_depends_on = unserialize($row['migration_depends_on'], ['allowed_classes' => false]);
128+
$old_depends_on = is_array($old_depends_on) ? $old_depends_on : [];
129+
$depends_on = array_map([$this, 'new_class_name'], $old_depends_on);
130+
$name = $this->new_class_name($row['migration_name']);
131+
132+
if ($name === $row['migration_name'] && $depends_on === $old_depends_on)
123133
{
124134
continue;
125135
}
126136

127-
$depends_on = unserialize($row['migration_depends_on'], ['allowed_classes' => false]);
128-
$depends_on = is_array($depends_on) ? array_map([$this, 'new_class_name'], $depends_on) : [];
129-
130137
$db->sql_query('UPDATE ' . $prefix . 'migrations SET ' . $db->sql_build_array('UPDATE', [
131-
'migration_name' => $this->new_class_name($row['migration_name']),
138+
'migration_name' => $name,
132139
'migration_depends_on' => serialize($depends_on),
133140
]) . " WHERE migration_name = '" . $db->sql_escape($row['migration_name']) . "'");
134141
}

‎language/en/install_editedpostsunread.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@
4040

4141
$lang = array_merge($lang, [
4242
'EDITEDPOSTSUNREAD_NOT_ENABLEABLE' => 'Mark Edited Posts Unread could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.',
43+
'EDITEDPOSTSUNREAD_DISABLE_OLD' => 'Disable the old “%s” extension first. Keep its data; do not delete it.',
4344
]);

0 commit comments

Comments
 (0)