com web/bugs: Fix #62088: Missing changelog entry when adding patch: www/patch-add.php
| From: | Peter Kokot | Date: | Tue, 21 May 2019 23:13:15 +0000 |
| Subject: | com web/bugs: Fix #62088: Missing changelog entry when adding patch: www/patch-add.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-28053@lists.php.net to get a copy of this message | ||
Commit: 3c344392bdbb711da6c6cbc0611fe4fbc19f1599
Author: Peter Kokot <peterkokot@gmail.com> Wed, 22 May 2019 01:13:15 +0200
Parents: 80abfff45301cb69fcd992a911ed6925625455e6
Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=3c344392bdbb711da6c6cbc0611fe4fbc19f1599
Log:
Fix #62088: Missing changelog entry when adding patch
Bugs:
https://bugs.php.net/62088
Changed paths:
M www/patch-add.php
Diff:
diff --git a/www/patch-add.php b/www/patch-add.php
index 76e34f0..9429ced 100644
--- a/www/patch-add.php
+++ b/www/patch-add.php
@@ -21,39 +21,39 @@ $canpatch = true;
/// Input vars
$bug_id = !empty($_REQUEST['bug']) ? (int) $_REQUEST['bug'] : 0;
if (empty($bug_id)) {
- $bug_id = !empty($_REQUEST['bug_id']) ? (int) $_REQUEST['bug_id'] : 0;
+ $bug_id = !empty($_REQUEST['bug_id']) ? (int) $_REQUEST['bug_id'] : 0;
}
if (empty($bug_id)) {
- response_header('Error :: no bug selected');
- display_bug_error('No bug selected to add a patch to (no bug or bug_id!)');
- response_footer();
- exit;
+ response_header('Error :: no bug selected');
+ display_bug_error('No bug selected to add a patch to (no bug or bug_id!)');
+ response_footer();
+ exit;
}
$bugRepository = $container->get(BugRepository::class);
if (!($buginfo = $bugRepository->findOneById($bug_id))) {
- response_header('Error :: invalid bug selected');
- display_bug_error("Invalid bug #{$bug_id} selected");
- response_footer();
- exit;
+ response_header('Error :: invalid bug selected');
+ display_bug_error("Invalid bug #{$bug_id} selected");
+ response_footer();
+ exit;
}
$package_name = $buginfo['package_name'];
// captcha is not necessary if the user is logged in
if (!$logged_in) {
- $captcha = $container->get(Captcha::class);
+ $captcha = $container->get(Captcha::class);
}
$show_bug_info = bugs_has_access($bug_id, $buginfo, $pw, $user_flags);
if (!$show_bug_info) {
- response_header('Private report');
- display_bug_error("The bug #{$bug_id} is not available to public");
- response_footer();
- exit;
+ response_header('Private report');
+ display_bug_error("The bug #{$bug_id} is not available to public");
+ response_footer();
+ exit;
}
$patch_name = (!empty($_GET['patchname']) &&
is_string($_GET['patchname'])) ? $_GET['patchname'] : '';
@@ -61,79 +61,77 @@ $patch_name = (!empty($_POST['name']) &&
is_string($_POST['name'])) ? $_POST['na
$patch_name_url = urlencode($patch_name);
if (isset($_POST['addpatch'])) {
- if (!isset($_POST['obsoleted'])) {
- $_POST['obsoleted'] = [];
- }
-
- // Check that patch name is given (required always)
- if (empty($patch_name)) {
- $patches = $patchRepository->findAllByBugId($bug_id);
- $errors[] = 'No patch name entered';
- include "{$ROOT_DIR}/templates/addpatch.php";
- exit;
- }
-
- if (!$logged_in) {
- try {
- $errors = [];
-
- $email = isset($_POST['email']) ? $_POST['email'] : '';
-
- if (!is_valid_email($email, $logged_in)) {
- $errors[] = 'Email address must be valid!';
- }
-
- /**
- * Check if session answer is set, then compare
- * it with the post captcha value. If it's not
- * the same, then it's an incorrect password.
- */
- if (!isset($_SESSION['answer']) || $_POST['captcha'] !=
$_SESSION['answer']) {
- $errors[] = 'Incorrect Captcha';
- }
-
- if (count($errors)) {
- throw new \Exception('');
- }
-
- try {
- $revision = $patchTracker->attach($bug_id, 'patch', $patch_name, $email,
$_POST['obsoleted']);
- } catch (\Exception $e) {
- $patches = $patchRepository->findAllByBugId($bug_id);
- $errors[] = $e->getMessage();
- $errors[] = 'Could not attach patch
"'.htmlspecialchars($patch_name).'" to Bug #'.$bug_id;
- include "{$ROOT_DIR}/templates/addpatch.php";
-
- exit;
- }
-
- redirect("patch-display.php?bug={$bug_id}&patch={$patch_name_url}&revision={$revision}");
- } catch (\Exception $e) {
- $patches = $patchRepository->findAllByBugId($bug_id);
- include "{$ROOT_DIR}/templates/addpatch.php";
- exit;
- }
- } else {
- $email = $auth_user->email;
- }
-
- try {
- $revision = $patchTracker->attach($bug_id, 'patch', $patch_name,
$auth_user->email, $_POST['obsoleted']);
- } catch (\Exception $e) {
- $patches = $patchRepository->findAllByBugId($bug_id);
- $errors = [
- $e->getMessage(),
- 'Could not attach patch "'.htmlspecialchars($patch_name, ENT_QUOTES).'"
to Bug #'.$bug_id
- ];
- include "{$ROOT_DIR}/templates/addpatch..php";
-
- exit;
- }
-
- // Add a comment to the bug report.
- $patch_url =
"{$site_method}://{$site_url}{$basedir}/patch-display.php?bug={$bug_id}&patch={$patch_name_url}&revision={$revision}";
-
- $text = <<<TXT
+ if (!isset($_POST['obsoleted'])) {
+ $_POST['obsoleted'] = [];
+ }
+
+ // Check that patch name is given (required always)
+ if (empty($patch_name)) {
+ $patches = $patchRepository->findAllByBugId($bug_id);
+ $errors[] = 'No patch name entered';
+ include "{$ROOT_DIR}/templates/addpatch.php";
+ exit;
+ }
+
+ if (!$logged_in) {
+ try {
+ $errors = [];
+
+ $email = isset($_POST['email']) ? $_POST['email'] : '';
+
+ if (!is_valid_email($email, $logged_in)) {
+ $errors[] = 'Email address must be valid!';
+ }
+
+ /**
+ * Check if session answer is set, then compare
+ * it with the post captcha value. If it's not
+ * the same, then it's an incorrect password.
+ */
+ if (!isset($_SESSION['answer']) || $_POST['captcha'] !=
$_SESSION['answer']) {
+ $errors[] = 'Incorrect Captcha';
+ }
+
+ if (count($errors)) {
+ throw new \Exception('');
+ }
+
+ try {
+ $revision = $patchTracker->attach($bug_id, 'patch', $patch_name,
$email, $_POST['obsoleted']);
+ } catch (\Exception $e) {
+ $patches = $patchRepository->findAllByBugId($bug_id);
+ $errors[] = $e->getMessage();
+ $errors[] = 'Could not attach patch
"'.htmlspecialchars($patch_name).'" to Bug #'.$bug_id;
+ include "{$ROOT_DIR}/templates/addpatch.php";
+
+ exit;
+ }
+ } catch (\Exception $e) {
+ $patches = $patchRepository->findAllByBugId($bug_id);
+ include "{$ROOT_DIR}/templates/addpatch.php";
+ exit;
+ }
+ } else {
+ $email = $auth_user->email;
+
+ try {
+ $revision = $patchTracker->attach($bug_id, 'patch', $patch_name,
$auth_user->email, $_POST['obsoleted']);
+ } catch (\Exception $e) {
+ $patches = $patchRepository->findAllByBugId($bug_id);
+ $errors = [
+ $e->getMessage(),
+ 'Could not attach patch "'.htmlspecialchars($patch_name,
ENT_QUOTES).'" to Bug #'.$bug_id
+ ];
+ include "{$ROOT_DIR}/templates/addpatch.php";
+
+ exit;
+ }
+ }
+
+ // Add a comment to the bug report.
+ $patch_url =
"{$site_method}://{$site_url}{$basedir}/patch-display.php?bug={$bug_id}&patch={$patch_name_url}&revision={$revision}";
+
+ $text = <<<TXT
The following patch has been added/updated:
Patch Name: {$patch_name}
@@ -141,15 +139,15 @@ Revision: {$revision}
URL: {$patch_url}
TXT;
- $res = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $text,
'patch');
+ $res = bugs_add_comment($bug_id, $email, $auth_user->name, $text, 'patch');
- // Send emails
- mail_bug_updates($buginfo, $buginfo, $auth_user->email, $text, 4, $bug_id);
+ // Send emails
+ mail_bug_updates($buginfo, $buginfo, $email, $text, 4, $bug_id);
- $patches = $patchRepository->findAllByBugId($bug_id);
- $errors = [];
- include "{$ROOT_DIR}/templates/patchadded.php";
- exit;
+ $patches = $patchRepository->findAllByBugId($bug_id);
+ $errors = [];
+ include "{$ROOT_DIR}/templates/patchadded.php";
+ exit;
}
$email = isset($_GET['email']) ? $_GET['email'] : '';