aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2016-07-23 20:54:16 +0700
committerrxu <rxu@mail.ru>2016-07-23 21:34:05 +0700
commiteaafb758ce5be55dd762c039fd7a746aa6c64b58 (patch)
tree65fe7faff196ac61a89d2f2039d1a0a56ba45fb1 /phpBB/phpbb
parent652e3da28d11157fe281c1252c74575798cf852f (diff)
downloadforums-eaafb758ce5be55dd762c039fd7a746aa6c64b58.tar
forums-eaafb758ce5be55dd762c039fd7a746aa6c64b58.tar.gz
forums-eaafb758ce5be55dd762c039fd7a746aa6c64b58.tar.bz2
forums-eaafb758ce5be55dd762c039fd7a746aa6c64b58.tar.xz
forums-eaafb758ce5be55dd762c039fd7a746aa6c64b58.zip
[ticket/14703] Select the parent module id from the several found
PHPBB3-14703
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index ed8162b81e..0869ce37d3 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -158,7 +158,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
$data = array('module_langname' => $data);
}
- $parent = $data['parent_id'] = $this->get_parent_module_id($parent);
+ $parent = $data['parent_id'] = $this->get_parent_module_id($parent, $data);
if (!isset($data['module_langname']))
{
@@ -463,10 +463,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
* Get parent module id
*
* @param string|int $parent_id The parent module_id|module_langname
+ * @param array $data The module data array
* @return int The parent module_id
* @throws \phpbb\db\migration\exception
*/
- public function get_parent_module_id($parent_id)
+ public function get_parent_module_id($parent_id, $data = array())
{
// Allow '' to be sent as 0
$parent_id = $parent_id ?: 0;
@@ -492,8 +493,26 @@ class module implements \phpbb\db\migration\tool\tool_interface
break;
// Several modules with the given module_langname were found
+ // Try to determine the parent_id by the neighbour module parent
default:
- throw new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id);
+ if (!empty($data) && (isset($data['before']) || isset($data['after'])))
+ {
+ $neighbour_module_langname = isset($data['before']) ? $data['before'] : $data['after'];
+ $sql = 'SELECT parent_id
+ FROM ' . MODULES_TABLE . '
+ WHERE module_langname ' . $this->db->sql_escape($neighbour_module_langname) . '
+ AND ' . $this->db->sql_in_set('parent_id', $ids);
+ $result = $this->db->sql_query($sql);
+ $parent_id = (int) $this->db->sql_fetchfield('parent_id');
+ if (!$parent_id)
+ {
+ throw new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']);
+ }
+ }
+ else
+ {
+ throw new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id);
+ }
break;
}
}