Modify

Opened 3 years ago

Closed 2 years ago

#9659 closed defect (fixed)

ResourceNotFound error when updating grid on ActiveTickets screen

Reported by: cgbrown Owned by: rjollos
Priority: normal Component: GridModifyPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by rjollos)

  • Trac 0.11.7
  • GridModify 0.1.3 and 0.1.5
  • Firefox 8.0.1 and Chrome 16.0.912.63

I take the following steps as a TRAC_ADMIN with the GridModify plugin enabled:

  1. Go to the View Tickets link
  2. Go to the Active Tickets Screen
  3. Attempt to update component

I get a red X back. When I run this in Firebug, I get a 500 error against a URL of the form:

https://server.example.com/path/to/trac/gridmod/update?ticket=323456789101112131415&component=component1

When I run the update link that is fired off as an AJAX call in my web browser, I get the message:

Oops...
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/GridModify-0.1.3-py2.5.egg/gridmod/web_ui.py", line 56, in process_request
    ticket = Ticket(self.env, id)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11.7-py2.5.egg/trac/ticket/model.py", line 50, in __init__
    self._fetch_ticket(tkt_id, db)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11.7-py2.5.egg/trac/ticket/model.py", line 102, in _fetch_ticket
    'Invalid Ticket Number')
ResourceNotFound: Ticket 323456789101112131415 does not exist.

It appears to be merging the ticket numbers from the entire grid. It renders the plugin unusable, unfortunately.

I'm going to take a look at the CSS selection that the JS is doing and see if I can propose a patch. Is there anything I'm doing wrong or should be considering when evaluating the issue here?

Attachments (2)

grid_modify_plugin_jquery_parent_patch.diff (718 bytes) - added by cgbrown 3 years ago.
Patch to make it choose one tr parent instead of all of them.
DomStructure.png (31.5 KB) - added by rjollos 2 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by cgbrown

  • Owner changed from bjornharrtell to cgbrown
  • Status changed from new to assigned

Changed 3 years ago by cgbrown

Patch to make it choose one tr parent instead of all of them.

comment:2 follow-up: Changed 3 years ago by cgbrown

  • Owner changed from cgbrown to bjornharrtell
  • Status changed from assigned to new

I've attached a proposed fix. Inspection in Firebug and Web Inspector showed me that on line 75 of the gridmod.js file, $(this).parents('tr') was returning all of the parents. The text was being concatenated, which produced the problem. I replaced that with $(this).parent('td').parent('tr'), which calls the ancestor directly above the line in question and no others. This seemed to fix the problem on our servers.

This would have been a showstopper if it happened for everyone, so the most likely cause is a difference or change in jQuery semantics, depending on what version of jQuery you're running. It's possible that in some versions .parents() returns the first ancestor that fits instead of all of them. Our Trac appears to be running jQuery 1.2.6.

At any rate, the fix above should work in both cases. I'll reassign to the project owner for review and committing at his leisure.

comment:3 Changed 2 years ago by rjollos

  • Description modified (diff)

comment:4 Changed 2 years ago by rjollos

  • Description modified (diff)

comment:5 Changed 2 years ago by rjollos

  • Owner changed from bjornharrtell to rjollos
  • Status changed from new to assigned

comment:6 in reply to: ↑ 2 Changed 2 years ago by rjollos

Replying to cgbrown:

I've attached a proposed fix. Inspection in Firebug and Web Inspector showed me that on line 75 of the gridmod.js file, $(this).parents('tr') was returning all of the parents. The text was being concatenated, which produced the problem.

Do you mean, the parent tr and all of its siblings, or were you finding that the element had multiple parent trs? The only way I can see this bug happening is if the immediate tr had a parent tr itself, or the parents method was returning the tr and siblings of the tr. The documentation doesn't indicate that the siblings should be returned though, and I don't see that the tr has a parent tr itself when inspecting the DOM in Trac 0.11.7 (Chrome 22). A variant of your patch doesn't seem harmful though, and should make the application more robust regardless of what the problem is here.

If you have a chance, could you send me the DOM structure that exists in the scenario in which you can reproduce this issue? Also, please let me know what other plugins you are running. Finally, after gathering that information, please upgrade to incorporate the change I'm about to commit if you can, and report back if it fixes the problem for you.

Changed 2 years ago by rjollos

comment:7 Changed 2 years ago by rjollos

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [12225]) Fixes #9659:

  • Navigate the DOM more precisely to get the ticket id, by capturing just the parent tr, then its sibling with class .ticket (Trac 0.11.7) or .id (Trac 0.11). This should make the plugin more robust to template modifications. Note that we can't use closest since Trac 0.11 supports jQuery 1.2 and closest was added in jQuery 1.3.
  • Added support for console logging in Chrome, as described in http://stackoverflow.com/a/2757552.

Add Comment

Modify Ticket

Action
as closed The owner will remain rjollos.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.