Page MenuHomePhabricator

"TypeError: parsers[j] is undefined" when sorting a table by a certain column
Closed, ResolvedPublic

Description

  1. Go to https://en.wikipedia.org/wiki/Comparison_of_disk_encryption_software?debug=1#Operating_systems
  2. Click twice on the "Android" column
  3. Click once in the "Linux" column

Expected behavior
The table would be sorted by that column

Actual result

{
	"errorMessage": "TypeError: parsers[j] is undefined",
	"url": "https://en.wikipedia.org/static/1.26wmf13/resources/src/jquery/jquery.tablesorter.js",
	"lineNumber": 210,
	"columnNumber": 4,
	"errorObject": {}
}

from the line

cols.push( parsers[j].format( getElementSortKey( $row[0].cells[j] ), table, $row[0].cells[j] ) );

of
https://github.com/wikimedia/mediawiki/blob/1f54fccca868fa4862df95245957f3028c67336e/resources/src/jquery/jquery.tablesorter.js#L210

By the time the error happens, i===0, j===10 and parsers.length===10 (so there is only parsers[0] to parsers[9], and parsers[j] is undefined).

Event Timeline

He7d3r created this task.Jul 13 2015, 7:28 PM
He7d3r updated the task description. (Show Details)
He7d3r raised the priority of this task from to Needs Triage.
He7d3r added a subscriber: He7d3r.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 13 2015, 7:28 PM
TheDJ added a subscriber: TheDJ.Jul 13 2015, 7:30 PM

Yeah, i sort of knew about this problem. Happens when you have incomplete rows in your table.

Change 233168 had a related patch set uploaded (by MatthiasDD):
jquery.tablesorter: Add ability for cells with colspan in tbody

https://gerrit.wikimedia.org/r/233168

Change 233168 merged by jenkins-bot:
jquery.tablesorter: Add ability for cells with colspan in tbody

https://gerrit.wikimedia.org/r/233168

TheDJ closed this task as Resolved.Sep 10 2015, 7:22 PM
TheDJ assigned this task to MatthiasDD.
TheDJ removed a project: Patch-For-Review.
TheDJ set Security to None.