Skip to content

Admin Order "Comments History" tab may be out of order #34304

Open
@PromInc

Description

@PromInc

In the Magento admin the comments history for an order is displayed in two locations - the Information tab and the Comments History tab.

The Information tab correctly sorts the comments (by created_at DESC and entity_id DESC)

However the Comments History tab ONLY sorts by created_at and thus the information can be inaccurate IF there are multiple records per order at the exact same second.

If you are using the Kount module it updates the order status when the order is placed - typically in 1 second or less. Thus this module frequently creates this bug.

The status history collection queries with the correct sorting in vendor/magento/module-sales/Model/Order.php::getStatusHistoryCollection. But that collection is later resorted in vendor/magento/module-sales/Block/Adminhtml/Order/View/Tab/History.php::getFullHistory for the Comments History tab and function only sorts by timestamp.
usort($history, [__CLASS__, 'sortHistoryByTimestamp']);

Preconditions (*)

  1. 2.4.2-p2

Steps to reproduce (*)

  1. Ensure the database has 2 records recorded at the same timestamp (to the second) for an order in table sales_order_status_history
  2. Navigate to the order in the admin
  3. Select the Comments History tab

Expected result (*)

  1. The comments would be ordered by created_at and entity_id

Actual result (*)

  1. The comments are ordered by created_at only

Here is the database record sorted correctly with created_at DESC and entity_id DESC.

mysql> SELECT entity_id, parent_id, created_at, status, comment FROM sales_order_status_history WHERE parent_id = 2225512 ORDER BY created_at DESC, entity_id DESC;
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
| entity_id | parent_id | created_at          | status       | comment                                                       |
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
|   9932939 |   2225512 | 2021-09-09 22:41:35 | complete     | Vertex Invoice sent successfully. Amount: $57.90              |
|   9932246 |   2225512 | 2021-09-09 20:00:18 | picking      | picking                                                       |
|   9932124 |   2225512 | 2021-09-09 19:45:31 | processing   | Order status updated from Kount.                              |
|   9932123 |   2225512 | 2021-09-09 19:45:30 | review_kount | Kount ENS Notification: Modify status of an order by agent.   |
|   9931424 |   2225512 | 2021-09-09 16:46:45 | review_kount | Order on review from Kount.                                   |
|   9931423 |   2225512 | 2021-09-09 16:46:45 | processing   | Captured amount of $661.60 online. Transaction ID: "5wxpptgs" |
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
6 rows in set (0.00 sec)

And on the Information tab you see that the status of Processing is correctly listed before the status of Review.
image

But here on the Comments History tab you can see that the Processing and Review statues have been flipped.
image


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
    Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
    Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
    Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
    Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Activity

m2-assistant

m2-assistant commented on Oct 11, 2021

@m2-assistant

Hi @PromInc. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

added
Severity: S3Affects non-critical data or functionality and does not force users to employ a workaround.
on Oct 12, 2021
self-assigned this
on Oct 19, 2021
m2-assistant

m2-assistant commented on Oct 19, 2021

@m2-assistant

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

    3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

    5. Add label Issue: Confirmed once verification is complete.

    6. Make sure that automatic system confirms that report has been added to the backlog.

engcom-Delta

engcom-Delta commented on Oct 19, 2021

@engcom-Delta
Contributor

Hi @PromInc ,
We have tested this issue on Magento 2.4 Develop latest branch , observed comments ordered by created_at and entity_id in DB.
but on UI is in different order .Kindly review once.
comments_Order
comments_History

PromInc

PromInc commented on Oct 19, 2021

@PromInc
Author

@engcom-Delta,
Thank you for the followup.

The section of the page that I'm addressing is the top half (above the Notes for this Order heading).

From your screenshot it's hard to tell the issue as Magento doesn't render the comments and the statuses are all set the same. But the top 3 records in that top section are the ones that are likely out of order.

image

You could test this by changing the statues in the database as follows and see what order they render in.

entity_id: 9, status: pending1
entity_id: 10, status: pending2
entity_id: 11, status: pending3

engcom-Delta

engcom-Delta commented on Oct 19, 2021

@engcom-Delta
Contributor

Hi @PromInc,
Please find below order after changing the status in DB.
comments_history_UI_afterUpdteinDB

in DB:
image

PromInc

PromInc commented on Oct 19, 2021

@PromInc
Author

@engcom-Delta,
By having the status the same for those three records you are obscuring the issue.

I'm using the Kount module which creates different statuses in the same second (processing then review). The point of this issue isn't whether or not they show up - it's whether or not they show up in the correct order. Your screenshots don't indicate the order in which the entity_id's show up. That's why I suggested using a different status per entity_id to see if the history is displayed in chronological order (sorted by created_at then entity_id). In my experience they don't.

added
Severity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.
on Oct 21, 2021

21 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: Cart & CheckoutComponent: BackendIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Severity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.

Type

No type

Projects

Status

Pull Request In Progress

Milestone

No milestone

Relationships

None yet

    Participants

    @PromInc@engcom-Alfa@engcom-Delta@github-jira-sync-bot

    Issue actions

      Admin Order "Comments History" tab may be out of order · Issue #34304 · magento/magento2