jenkins-bot has submitted this change and it was merged.

Change subject: Images: validate image id before adapting to prevent js error
......................................................................


Images: validate image id before adapting to prevent js error

Images not having an identifier can cause js error and can even
prevent any auto save happening further.

Testplan:
Translate enwiki:Amblydoras to es. Add the last section about
stub article. Console will show a js error and adding any other
secton after this won't trigger autosave. With this patch, there
should not be a js error and save should work as expected.

Bug: T108809
Change-Id: I18affd6927d391469db9e1c6445fa98a4f760f5c
(cherry picked from commit 7443c8ccd15d4d0afe105849633bb765ad623945)
---
M modules/tools/ext.cx.tools.images.js
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Thcipriani: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/tools/ext.cx.tools.images.js 
b/modules/tools/ext.cx.tools.images.js
index 08a7190..bb10b82 100644
--- a/modules/tools/ext.cx.tools.images.js
+++ b/modules/tools/ext.cx.tools.images.js
@@ -92,10 +92,14 @@
                var targetLanguage = mw.cx.targetLanguage;
 
                $section.find( 'img' ).each( function () {
-                       var $sourceSection, $sourceImage, $image = $( this );
+                       var imageId, $sourceSection, $sourceImage, $image = $( 
this );
 
+                       imageId = $image.prop( 'id' );
+                       if ( !imageId ) {
+                               return;
+                       }
                        $sourceSection = mw.cx.getSourceSection( $section.data( 
'source' ) );
-                       $sourceImage = $sourceSection.find( '#' + $image.prop( 
'id' ) );
+                       $sourceImage = $sourceSection.find( '#' + imageId );
                        $image.on( 'click', function ( event ) {
                                // Avoid opening images by clicking.
                                event.preventDefault();

-- 
To view, visit https://gerrit.wikimedia.org/r/231230
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I18affd6927d391469db9e1c6445fa98a4f760f5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: wmf/1.26wmf18
Gerrit-Owner: KartikMistry <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: Thcipriani <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to