Page MenuHomePhabricator

Add another argument in SpecialRandompage.php to allow exclusion of blank pages
Closed, DeclinedPublic

Description

Author: tisane2718

Description:
Presently, exclusion of blank pages from the "Random Page" special page is implemented as a separate special page, Special:RandomExcludeBlank, in Extension:PureWikiDeletion (see http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/PureWikiDeletion/SpecialPureWikiDeletion.php?view=markup ), whose code is a fork of SpecialRandomPage.php. Rather than forking the code, it seems like it would be better to just add a boolean argument in the core that, if true, would cause blank pages to be excluded. There might be other wikis not using PureWikiDeletion that nonetheless have some blank pages they would want to exclude from showing up on "Random Page" requests.

I suppose the easiest implementation would be to select a random page, check to see if it's blank, and if it is, then select a different random page; and keep doing that until a non-blank page is found.


Version: unspecified
Severity: enhancement

Details

Reference
bz23843

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:10 PM
bzimport set Reference to bz23843.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Jun 8 2010, 6:02 PM

tisane2718 wrote:

Patch to fix this bug

Introduces two new arguments, $excludeBlank and $attempts. If $excludeBlank is true, it will make $attempts number of attempts to find a non-blank page before giving up and telling the user that a non-blank page was not found.

The code I used to test it is:

class RandomExcludeBlank extends SpecialPage {
function __construct( $name = 'RandomExcludeBlank' ){

		parent::__construct( $name );
		$this->setGroup('RandomExcludeBlank'
			,'redirects');

}

public function execute( $par ) {

		global $wgPureWikiDeletionRandomPageAttempts;
		$randomPageObj = new RandomPage;
		$randomPageObj->execute ( $par, true, $wgPureWikiDeletionRandomPageAttempts );
		return true;

}
}

attachment random_patch ignored as obsolete

tisane2718 wrote:

Then again, if we assume users are using Extension:PureWikiDeletion, a better way to do this would be to run the query: SELECT page.page_id
FROM page LEFT JOIN blanked_page ON page.page_id = blanked_page.blank_page_id
WHERE blanked_page.blank_page_id IS NULL

That would provide an object containing all the rows in the page table that are not in the blanked_page table. Then there would be a 100% chance of finding a non-blank page on the first try, assuming there are any non-blank pages in the namespace(s) being searched.

You could JOIN revision ON page_latest = rev_id and check rev_len > 0

tisane2718 wrote:

Finds a nonblank page in one try.

This patch doesn't use $attempts as the other patch did, and it uses a JOIN to select from among nonblank pages, if $excludeBlank is true.

Attached:

Looks good. But how is $excludeBlank going to be true? Take into account that execute() is called from the parent class SpecialPage.

You are using "revision" directly. You should use $dbr->tableName() to take into account prefixed installs.

You are changing SpecialRandomGetRandomTitle but not updating hooks.txt I'm not sure if it makes sense to pass $excludeBlank by reference there.

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

tisane, thank you for your patch. I'm marking it "reviewed" per Platonides's review in comment 5. If you have the time and the interest to revise it, please go ahead and submit a revised patch. Thanks!

(In reply to comment #7)

tisane, If you have the time and the interest to revise it
please go ahead and submit a revised patch. Thanks!

No feedback => assuming that nobody is currently working on it, resetting assignee and ASSIGNED status.

demon removed a subscriber: demon.Aug 19 2015, 5:23 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 19 2015, 5:23 PM
Mainframe98 closed this task as Declined.Jun 18 2019, 8:08 AM
Mainframe98 added a subscriber: Mainframe98.

There have been no additional requests for this feature, and the extension this was requested for is archived: T225991: Archive the PureWikiDeletion extension.