Page MenuHomePhabricator

Insert link not working for looks-like-internal
Closed, ResolvedPublic

Description

As reported at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=1054598407#Insert_link_feature_not_behaving_like_expected_for_external_links_converted_to_internal_links._Is_it_the_problem_or_am_I%3F

The insert-link dialog has the option to convert an external link to an internal one when the wiki's own URL is given as the link target. This happens in a popup that appears when the link is inserted, letting the user choose between converting the URL or inserting it as-is.

With the switch to OOUI widgets, the converting function has broken, and should be fixed.

Event Timeline

(Reposted from WP:VPT)
Replacing this line with insertLinkTitleInputField.getField().setValue( match[ 1 ] ); seems to do the job, but I'm surprised the function 1) keeps underscores instead of turning them into spaces and 2) doesn't decode percent encodings. I bet users of wikis in other languages have found it useless.

Change 738599 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/WikiEditor@master] Fix bug when target looks like internal link

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

We should def honor the previous functionality if it used to convert it accordingly. Will prioritize in the to be estimated column so we could add to sprint

Change 738599 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] Fix bug when target looks like internal link

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

@Samwilson I am finding that when I get the dialog asking me whether I want an internal or external link, if I click "Internal link" the "To an external web page" radio is still selected. If I don't notice this, I will end up entering an invalid link.

This was not the case before (in WikiEditor 0.5.3 (afa4f07) 06:14, 19 August 2021). Selecting "Internal link" would also select the "To wiki page" radio button.

Enter a full URL:

looks_like_internal_step1.png (318×528 px, 23 KB)

Click "Insert link":

looks_like_internal_step2.png (313×519 px, 24 KB)

Click "Internal link":

looks_like_internal_step3.png (315×516 px, 18 KB)

(But the "To an external web page" radio is still selected)

Click "Insert link":

looks_like_internal_outcome.png (33×574 px, 2 KB)

Outcome is: [http://Major_Minor%27s_Majestic_March Major_Minor%27s_Majestic_March]

Change 745127 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/WikiEditor@master] Set link type radio when confirming looks-like internal

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

Notes for QA:

  1. Using the source editor, start editing any page on beta (e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Special:Random)
  2. Open the "Insert link" dialog
    insert_link_menu_item.png (305×1 px, 44 KB)
  3. Find any other page on the same beta wiki. Copy the entire URL from the address bar.
  4. In the first input field, enter the full URL you copied in step 3.
  5. Click "Insert link" or press enter.
  6. You should see a dialog like below.
    looks_like_internal_step2.png (313×519 px, 24 KB)
  7. Depending on which of the two buttons you click on in this dialog, one of two things will happen:
    • a) If you click "Internal link", the URL you entered will be stripped down so only the page's title will display (e.g. Selenium_diff_test_0.18270253102627854) and the "To a wiki page" radio button will be selected. If you then click "Insert link" an internal link will be added to the page. This will be something like [[Selenium_diff_test_0.18270253102627854]].
      click_internal_link.png (349×524 px, 23 KB)
    • b) If you click "External link", the URL you entered should be untouched and it will insert an external link. Something like https://en.wikipedia.beta.wmflabs.org/wiki/Selenium%20diff%20test%200.18270253102627854 or [https://en.wikipedia.beta.wmflabs.org/wiki/Selenium%20diff%20test%200.18270253102627854 https://en.wikipedia.beta.wmflabs.org/wiki/Selenium diff test 0.18270253102627854].
    • N.B. Currently I notice that b) inserts the wikitext immediately after you click "External link" whereas a) takes you back to the "Insert link" dialog. I don't know if this behaviour is desirable.

Things to remember:

  • Consider regressions:
    • Test that you can still successfully enter an external link to another website (could be anything like http://duckduckgo.com)
    • Test you can still enter an internal link (e.g. enter just the title of another page on the same wiki like Polar_bear)
  • If possible, compare the behaviour of the "Insert link" dialog now to an earlier version. I think you can only do this if you set it up locally.
    • I put instructions how to install it locally here. After you have installed it locally, to get the older version of the software, do:
      • cd extensions/WikiEditor
      • git checkout fd74287b2f234ca33f7af8a227dd4b0c51d2a7b5
  • Experiment with different ways of interacting with the dialog, such as pressing the enter key to submit.
  • I have found some inconsistency in the behaviour of the "Insert link" dialog when using it to add multiple links in the same session.
    • Try repeating adding a link several times in a row and see if the outcome is the same each time. (For an example of a bug like this see T297371)
    • Try closing the dialog and reopening it. It normally returns to the same state it was in when you closed it.

(I have centralised some of these ideas here: Things to consider when testing)

Change 745127 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] Set link type radio when confirming looks-like internal

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

Confirmed that user is able to insert link as internal and also verified above QA notes works as expected

Screen Shot 2021-12-22 at 4.50.48 PM.png (1×2 px, 331 KB)

Screen Shot 2021-12-22 at 4.52.11 PM.png (1×2 px, 320 KB)

Screen Shot 2021-12-22 at 5.15.45 PM.png (1×2 px, 341 KB)

Hiya -- I'm the one who initially reported this issue and I just used it today and it's better (hooray!) still not working as expected. The expectation is: if I enter a Wikipedia URL, and the tool asks me if I want to change it to an internal link, it does not also change the radio button to "internal link" if I answer in the affirmative. So as a result the link it includes is invalid, just http://PAGENAME (also shouldn't that be https?). Here's a few screenshots.... The previous behavior was that when you said "Yes I want an internal link" the tool would also change the radio button. I don't mind this, I can obviously click a button, but I think the expected result is that the tool would change this button. Thank you.

Screen Shot 2022-01-06 at 13.40.49.png (2×1 px, 245 KB)

Screen Shot 2022-01-06 at 13.46.08.png (134×622 px, 21 KB)

Hiya...

@Jessamyn Thanks for following up on this.

Hmmm, this is not the behaviour I see. Which wiki are you using?

I think this is the same as the bug I reported in T295517#7552310, which I thought had been fixed by T295517#7584028.

Perhaps the wiki is using the older version of WikiEditor which does not have that fix.

The only other thing I can think of is that perhaps your browser has cached the previous Javascript, which has this bug. Just to check, would you be able to hard-refresh the page, clear your browser cache or use a different browser? Thanks.

Hiya...

@Jessamyn Thanks for following up on this.

Hmmm, this is not the behaviour I see. Which wiki are you using?

Thank you. I am using English Wikipedia and the old school editor. If I switch to a different browser, I get the expected behavior, so I'll figure out if it's an add-on or some other caching that is causing this. Thank you for letting me know, problem is clearly on my end.

This does sound like it could be a caching issue. But @Jessamyn if you do see this error persisting in the original browser (which are the two browsers you're using, by the way?), please let us know.

Will do. I'm using Firefox (where I seem to see the caching issue) and Brave (where I do not and it functions correctly).

thanks for your help and input and @Jessamyn and thanks for solutioning @Samwilson