Page MenuHomePhabricator

JS error when editing Page NS pages that don't exist
Open, Needs TriagePublicBUG REPORT

Description

The following error appears when editing pages such as https://en.wikisource.org/w/index.php?title=Page:does_not_exist.pdf/2&action=edit which do not correspond to a page within an existing file:

TypeError: $prpImage.find(...)[0] is undefined

Coming from this code:

function ExtractTextWidget( ocrTool, $prpImage, $textbox ) {
	/* … */
	this.ocrTool.setImage( $prpImage.find( 'img' )[ 0 ].src );
	/* … */

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
TheresNoTime changed the subtype of this task from "Task" to "Bug Report".Aug 4 2022, 6:14 PM

@Soda I think you're touching code related to this for other reasons, so you may want to be aware of this task. In addition to $prpImage being undefined, pages such as this also trigger an error notification from OSD that there's no image.

I'm not sure what the optimal behaviour would be: the example case here should probably fail silent, but there may be other cases where the error messages are appropriate. And in either case the errors are "low level" errors rather than something user friendly that might help non-technical users figure out the problem and how to fix it.

@Soda I think you're touching code related to this for other reasons, so you may want to be aware of this task. In addition to $prpImage being undefined, pages such as this also trigger an error notification from OSD that there's no image.

I'm not sure what the optimal behaviour would be: the example case here should probably fail silent, but there may be other cases where the error messages are appropriate. And in either case the errors are "low level" errors rather than something user friendly that might help non-technical users figure out the problem and how to fix it.

It is interesting that the JS error for the Wikisource OCR still occurs. I assumed that my recent changes had fixed that :(

Wrt to the Openseadragon error, it isn't supposed to be a low-level error. We are explicitly showing that alert when we find no usable image and the text can be changed, let me know what would be a better wording :)

Change 866283 had a related patch set uploaded (by Sohom Datta; author: Sohom Datta):

[mediawiki/extensions/Wikisource@master] [Wikimedia OCR] Fix insufficient validation of image existence

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

Change 866283 merged by jenkins-bot:

[mediawiki/extensions/Wikisource@master] [Wikimedia OCR] Fix insufficient validation of image existence

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