Adding a comment in the Add an Admin comment text area at /admin/store/orders/XXX/edit

Message from dblog :

Drupal\Core\Database\IntegrityConstraintViolationException : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'order_id' cannot be null: INSERT INTO {uc_order_admin_comments} (order_id, uid, message, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => aaa [:db_insert_placeholder_3] => 1498785400 ) dans Drupal\Core\Database\Connection->handleQueryException() (ligne 682 de /home/ubuntu/workspace/core/lib/Drupal/Core/Database/Connection.php).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kiwad created an issue. See original summary.

TR’s picture

It works for me if I add the admin comment at /admin/store/orders/XXX but I get the same error as you when I try that at /admin/store/orders/XXX/edit.

TR’s picture

Status: Active » Needs review
FileSize
673 bytes

This should fix it.

TR’s picture

Actually, this is probably a better fix.

TR’s picture

Issue tags: +Needs tests

It seems we don't have any tests for adding order comments. There are four places this can be done:

  1. Admin comments may be added at admin/store/orders/{uc_order}
  2. Admin comments may be added at admin/store/orders/{uc_order}/edit
  3. Order (user) comments may be added at admin/store/orders/{uc_order}
  4. User comments may be added at cart/checkout

We should add test cases to ensure that adding order comments in all four of these places works. I'll defer committing this until the tests are written.

TR’s picture

Here's a patch containing a set of tests which test the four ways to add order comments which I listed above.

The test that tests scenario 2) should FAIL because of the reported bug.

TR’s picture

Now here's the same set of tests but this time with the fix from #4 included. These tests should all pass.

Status: Needs review » Needs work

The last submitted patch, 7: 2890917-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

TR’s picture

Hmm, there's still a problem with the test - I'm getting intermittent failures doing text comparisons between the randomly-generated comment text and what shows up on the page. I think it's an HTML escaping problem - I'd like to settle that before I commit the new tests.

TR’s picture

Status: Needs work » Needs review
FileSize
7.55 KB

OK, I ran this version 100 times locally without a fail - I think this should be good to go. This has the improved tests plus the fix from #4.

  • TR committed 314840e on 8.x-4.x
    Issue #2890917 by TR: Adding admin comment causes Fatal error
    
TR’s picture

Status: Needs review » Fixed

Committed #10.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.