From cf77557a95127ed90ab03e8027692a75d0c73aa3 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Thu, 21 Jul 2022 13:24:24 +0200 Subject: [PATCH] Fix "null is not a string" error in event logging code This getTitle() method can return null. Bug: T299779 Change-Id: I33c6fc0cdd03ae45a04d4098cf101dc9fa3414e3 --- modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js index 88c1c2f4ee..724e76a8a4 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js @@ -396,8 +396,10 @@ ve.ui.MWTemplateDialog.prototype.getActionProcess = function ( action ) { } var parts = dialog.transclusionModel.getParts(); for ( var i = 0; i < parts.length; i++ ) { - if ( parts[ i ].getTitle ) { - templateEvent.template_names.push( parts[ i ].getTitle() ); + // Only {@see ve.dm.MWTemplateModel} have a title + var title = parts[ i ].getTitle && parts[ i ].getTitle(); + if ( title ) { + templateEvent.template_names.push( title ); } } mw.track( 'event.VisualEditorTemplateDialogUse', templateEvent );