diff --git a/includes/objects/contribution.php b/includes/objects/contribution.php index 47d45a10e..df5b81608 100644 --- a/includes/objects/contribution.php +++ b/includes/objects/contribution.php @@ -536,13 +536,22 @@ public function get_download($revision_id = false) (($revision_id === false) ? ' AND r.revision_status = ' . ext::TITANIA_REVISION_APPROVED : '') . ' AND revision_submitted = 1'; $result = phpbb::$db->sql_query($sql); - $revisions = array_flip($revisions); + $rows = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { - $this->download[$revisions[$row['revision_id']]] = $row; + $rows[(int) $row['revision_id']] = $row; } phpbb::$db->sql_freeresult($result); + + // Branches sharing one latest revision each keep their own entry. + foreach ($revisions as $branch => $branch_revision_id) + { + if (isset($rows[$branch_revision_id])) + { + $this->download[$branch] = $rows[$branch_revision_id]; + } + } krsort($this->download); } } @@ -898,8 +907,16 @@ public function assign_download_details() titania::$config->colorizeit . '.html?sample=' . $this->clr_sample->get_id(); } + $displayed = array(); foreach ($this->download as $download) { + // A revision latest for several branches gets one download block. + if (isset($displayed[$download['revision_id']])) + { + continue; + } + $displayed[$download['revision_id']] = true; + $vendor_version = $install_level = $install_time = $u_colorizeit = ''; if (!empty($this->revisions[$download['revision_id']]['phpbb_versions'])) @@ -1078,17 +1095,21 @@ public function get_approved_branches() AND revision_status = ' . ext::TITANIA_REVISION_APPROVED . ' AND revision_submitted = 1'; $result = phpbb::$db->sql_query($sql); - $revisions = array_flip($revisions); // revision_id => branch - $approved = array(); + $approved_revisions = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { - $branch = (int) $revisions[(int) $row['revision_id']]; - if (isset($allowed_branches[$branch])) + $approved_revisions[(int) $row['revision_id']] = true; + } + phpbb::$db->sql_freeresult($result); + + $approved = array(); + foreach ($revisions as $branch => $branch_revision_id) + { + if (isset($approved_revisions[$branch_revision_id]) && isset($allowed_branches[$branch])) { $approved[$branch] = $allowed_branches[$branch]; } } - phpbb::$db->sql_freeresult($result); return $approved; } @@ -1221,17 +1242,30 @@ public function update_release_topic() $contrib_description = $this->contrib_desc; message::decode($contrib_description, $this->contrib_desc_uid); - $download = reset($this->download); // Just need the first download entry - $phpbb_versions = $this->revisions[$download['revision_id']]['phpbb_versions']; - foreach ($phpbb_versions as $phpbb_version) + // Each branch has its own latest download and its own release topic. + foreach ($this->download as $branch => $download) { - $branch = (int)$phpbb_version['phpbb_version_branch']; - if (empty($this->type->forum_database[$branch])) { continue; } + // The revision row for this branch carries the tested phpBB version. + $phpbb_version = false; + foreach ($this->revisions[$download['revision_id']]['phpbb_versions'] as $version_row) + { + if ((int) $version_row['phpbb_version_branch'] == $branch) + { + $phpbb_version = $version_row; + break; + } + } + + if ($phpbb_version === false) + { + continue; + } + $u_download = $this->controller_helper->route('phpbb.titania.download', array( 'id' => $download['attachment_id'] ));