Page MenuHomePhabricator

[[Special:RandomRootPage/]] returns also from other namespace than main only
Closed, ResolvedPublic

Description

[[Special:RandomRootPage/]] returns also from other namespace than main only.

Seems it returns either from content namespaces or 0 + any other even ns >= 100?

On cswikisouirce it returns from ns:0 and ns:100, which are both set as content ns.

It should return only main ns, because it is specified. (unlike [[Special:RandomRootPage]] which also returns ns:0 and ns:100 - assuming the content namespaces.)


Version: unspecified
Severity: minor
See Also:

Details

Reference
bz46420

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:37 AM
bzimport set Reference to bz46420.

Does this bug happen for [[Special:random]] too?

[[Special:Random]] is definitely problematic at this time (for English Wikisource) whether that was the case at that time is unknown.

neil wrote:

I am having a problem with randomrootpage on en.wikibooks where it has started to behave the same way as [[Special:Random]] returning pages that are not root pages.

neil wrote:

Problem appears to have started at en.wikibooks following the deployment of 1.24/wmf9

I guess the problem is that we're not using ElasticSearch to do the randomness.

Meaning the SQL query, and as such, the amended SQL query for Special:RandomRootPage isn't actually run...

Transplanting something like the below into the extension would fix this issue

/**

  • Choose a random title.
  • @return Title|null Title object (or null if nothing to choose from)
	 */

public function getRandomTitle() {

		$row = $this->selectRandomPageFromDB( wfRandom() );

		/* If we picked a value that was higher than any in
		 * the DB, wrap around and select the page with the
		 * lowest value instead!  One might think this would
		 * skew the distribution, but in fact it won't cause
		 * any more bias than what the page_random scheme
		 * causes anyway.  Trust me, I'm a mathematician. :)
		 */
		if ( !$row ) {
			$row = $this->selectRandomPageFromDB( "0" );
		}

		if ( $row ) {
			return Title::makeTitleSafe( $row->page_namespace, $row->page_title );
		}

		return null;

}

(In reply to Sam Reed (reedy) from comment #5)

I guess the problem is that we're not using ElasticSearch to do the
randomness.

now, not not.

I guess the problem is that we're now using ElasticSearch to do the randomness.

(In reply to billinghurst from comment #2)

[[Special:Random]] is definitely problematic at this time (for English
Wikisource) whether that was the case at that time is unknown.

I've split this to bug 66879. Lets keep separate bugs separate

For the original problem...

$this->namespaces = MWNamespace::getContentNamespaces();

Just need to modify $this->namespaces in the constructor on the extension

Change 140916 had a related patch set uploaded by Brian Wolff:
Allow specifying a random page only in main namespace

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

I also just discovered that doing Special:RandomRootPage/main should also work (and has for quite a while).

Change 140916 merged by jenkins-bot:
Allow specifying a random page only in main namespace

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

Should start working on July 29