Page MenuHomePhabricator

page links in Flow are parsed as relative hrefs, so they break in permalink, history and other views
Closed, ResolvedPublic

Description

When you put a [[Pagename]] link in Flow, Parsoid generates a link of the form
<a rel="mw:WikiLink" href="./Pagename" data-parsoid="{&qu blah blah ...

Note it's a relative link, not an absolute link. This works if you are viewing /wiki/User_talk:SomeBoard , but if you view a permalink, or view a diff, or even just http://ee-flow.wmflabs.org/w/index.php?title=User_talk:Spage , the relative href to /w/index.php becomes a link to /w/Pagename, which is a 404.

This feels like a Parsoid problem, but it might be addressed by ErikB's comment in ParsoidUtils.php,

// @todo needs a big refactor to get a page title in here, fake Main_Page for now

(Huge props to quiddity for noticing this one.)


Version: master
Severity: major
URL: ee-flow.wmflabs.org/w/index.php?title=User_talk:Spage&workflow=0508e9b63c8f34dffb6efa163e68c4ac

Details

Reference
bz56988

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:34 AM
bzimport set Reference to bz56988.
bzimport added a subscriber: Unknown Object (MLST).

The WMF core features team tracks this bug on Mingle card https://mingle.corp.wikimedia.org/projects/flow/cards/457, but people from the community are welcome to contribute here and in Gerrit.

On ee-flow labs instance, invoking Parsoid with

$ curl localhost:8000/localhost/ -d wt='[[Pagename]] here'

produces

...
<base href="http://ee-flow.wmflabs.org/wiki/Main Page"/>
</head>
<body data-parsoid='{"dsr":[0,318,0,0]}'>

<p data-parsoid='{"dsr":[0,318,0,0]}'>
  <a rel="mw:WikiLink" href="./Pagename" data-parsoid='{"stx":"simple","a":{"href":"./Pagename"},"sa":{"href":"Pagename"},"dsr":[0,313,2,2]}'>Pagename</a>
  here
</p>

...

Note the base href, which will make the href have the right /wiki/ prefix regardless of the current URL.
But Flow's parsing of the HTML returned by Parsoid ignores the base href, and it doesn't set base href in its own HTML HEAD. Flow could do this (assuming the base href will be the same for all items in the Flow board),
, or it could parse the HTML, or the the Parsoid API could have an option to generate full paths.

The HTML for [[Pagename]] on a regular wiki page is an absolute path -- href="/wiki/Pagename" , so Parsoid's behavior is different.

Note that some day a user's "My active threads" Flow board might show conversations from multiple wikis, so absolute URLs might be useful, some day.

Change 95563 had a related patch set uploaded by EBernhardson:
Hackish method of respecting parsoid base href

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

  • Bug 57161 has been marked as a duplicate of this bug. ***

Change 96189 had a related patch set uploaded by EBernhardson:
Workaround for relative links in /w/index.php

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

Change 95563 abandoned by EBernhardson:
Hackish method of respecting parsoid base href

Reason:
Going a different direction for the temporary fix, https://gerrit.wikimedia.org/r/96189

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

Change 96189 merged by jenkins-bot:
Workaround for relative links in /w/index.php

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