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

Change subject: TitleWidget: Take 'known' status into account when deciding 
page existence
......................................................................


TitleWidget: Take 'known' status into account when deciding page existence

Bug: T72123
Change-Id: Id00215946a9a1927967e8af7f321862e89261c51
---
M resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
1 file changed, 23 insertions(+), 4 deletions(-)

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



diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js 
b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
index b25b2d4..222586f 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
@@ -146,7 +146,13 @@
                                        }
                                        req = new mw.Api().get( params );
                                        promiseAbortObject.abort = 
req.abort.bind( req ); // TODO ew
-                                       return req;
+                                       return req.then( function ( ret ) {
+                                               if ( ret.query === undefined ) {
+                                                       ret = new mw.Api().get( 
{ action: 'query', titles: query } );
+                                                       
promiseAbortObject.abort = ret.abort.bind( ret );
+                                               }
+                                               return ret;
+                                       } );
                                }
                        } ).promise( promiseAbortObject );
                } else {
@@ -186,6 +192,7 @@
                                continue;
                        }
                        pageData[ suggestionPage.title ] = {
+                               known: suggestionPage.known !== undefined,
                                missing: suggestionPage.missing !== undefined,
                                redirect: suggestionPage.redirect !== undefined,
                                disambiguation: OO.getProp( suggestionPage, 
'pageprops', 'disambiguation' ) !== undefined,
@@ -205,6 +212,7 @@
                        for ( i = 0, len = redirects.length; i < len; i++ ) {
                                pageData[ redirects[ i ] ] = {
                                        missing: false,
+                                       known: true,
                                        redirect: true,
                                        disambiguation: false,
                                        description: mw.msg( 
'mw-widgets-titleinput-description-redirect', suggestionPage.title ),
@@ -222,14 +230,25 @@
                // If not found, run value through mw.Title to avoid treating a 
match as a
                // mismatch where normalisation would make them matching (bug 
48476)
 
-               pageExistsExact = titles.indexOf( this.getQueryValue() ) !== -1;
+               pageExistsExact = (
+                       Object.prototype.hasOwnProperty.call( pageData, 
this.getQueryValue() ) &&
+                       (
+                               !pageData[ this.getQueryValue() ].missing ||
+                               pageData[ this.getQueryValue() ].known
+                       )
+               );
                pageExists = pageExistsExact || (
-                       titleObj && titles.indexOf( titleObj.getPrefixedText() 
) !== -1
+                       titleObj &&
+                       Object.prototype.hasOwnProperty.call( pageData, 
titleObj.getPrefixedText() ) &&
+                       (
+                               !pageData[ titleObj.getPrefixedText() ].missing 
||
+                               pageData[ titleObj.getPrefixedText() ].known
+                       )
                );
 
                if ( !pageExists ) {
                        pageData[ this.getQueryValue() ] = {
-                               missing: true, redirect: false, disambiguation: 
false,
+                               missing: true, known: false, redirect: false, 
disambiguation: false,
                                description: mw.msg( 
'mw-widgets-titleinput-description-new-page' )
                        };
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id00215946a9a1927967e8af7f321862e89261c51
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <a...@wikimedia.org>
Gerrit-Reviewer: Alex Monk <a...@wikimedia.org>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to