Follow-up to #1986330: When Batch ID doesn't exist, Drupal should emit a 404

Problem/Motivation

Currently if you try to go to /batch?id=123 you get redirected to the homepage with a message stating "No active batch".

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Usability Bug, because the message "No active batch" is not clear, since no batch is ran and it does not exists. Response must help figure out what is going on actually.
Issue priority Normal, because this is a self-contained bug and does not impact the overall functionality of the software.
Unfrozen changes Not unfrozen because it changes automated tests and needs a bug fix.
Prioritized changes Prioritized, the main goal of this issue is a bug fix, usability and user experience improvement.
Disruption Impact on improving usability is fair. Also it doesn't disrupt core API because it is internal to batch API only.

Proposed resolution

Since the batch doesn't exist Drupal should just emit a 404 instead

User interface changes

N/A

API changes

If you try to go to /batch?id=123 Drupal emit a 404.

Comments

nikunjkotecha created an issue. See original summary.

nikunjkotecha’s picture

Status: Needs work » Needs review
StatusFileSize
new401 bytes

Adding patch for D7.

yago elias’s picture

Status: Needs review » Needs work
StatusFileSize
new677 bytes
new532 bytes

We should add a message log to the dblog system.

yago elias’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: d7_when_batch_id-2826866-3.patch, failed testing.

lomasr’s picture

StatusFileSize
new585 bytes

Adding a patch for Text change.Please review.

lomasr’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: d7_when_batch_id-2826866-6.patch, failed testing.

nikunjkotecha’s picture

Assigned: Unassigned » nikunjkotecha
nikunjkotecha’s picture

StatusFileSize
new519 bytes

Updated patch to include the message before drupal_exit().

nikunjkotecha’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: 2826866-10.patch, failed testing.

nikunjkotecha’s picture

Status: Needs work » Needs review

I'm not sure what's the error for fail as it shows nothing in error and it passed in simplytest.me for me.

nikunjkotecha’s picture

StatusFileSize
new112.91 KB

screenshot attached from simplytest.me

Status: Needs review » Needs work

The last submitted patch, 10: 2826866-10.patch, failed testing.

ajits’s picture

+++ b/includes/batch.inc
@@ -51,8 +51,9 @@ function _batch_page() {
+      watchdog('Batch', '@batch_id is not a valid batch id.', array('@batch_id' => $_REQUEST['id']), WATCHDOG_ERROR);

Can we get a better message? This sounds very technical.
How about

Trying to execute an invalid batch. ID : @batch_id

navneet0693’s picture

Agreed with comment in #16

navneet0693’s picture

+++ b/includes/batch.inc
@@ -51,8 +51,9 @@ function _batch_page() {
+      watchdog('Batch', '@batch_id is not a valid batch id.', array('@batch_id' => $_REQUEST['id']), WATCHDOG_ERROR);

It's just a suggest if we use % instead of @

cebasqueira’s picture

Status: Needs work » Needs review
StatusFileSize
new520 bytes
dinesh18’s picture

Verified and working as expected.

cebasqueira’s picture

Dinesh18 please change the status to RTBC

navneet0693’s picture

Status: Needs review » Reviewed & tested by the community
stefan.r’s picture

How does this work in Drupal 8? If it has the same issue, this should be fixed there first.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work

The Drupal 8 issue is the parent of this one (#1986330: When Batch ID doesn't exist, Drupal should emit a 404). Looks like it was just marked RTBC, but the two patches are not in sync. They use different wording, and (especially) this one is missing the automated test.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.