Last modified: 2014-09-24 00:07:30 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T25843, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 23843 - Add another argument in SpecialRandompage.php to allow exclusion of blank pages
Add another argument in SpecialRandompage.php to allow exclusion of blank pages
Status: NEW
Product: MediaWiki
Classification: Unclassified
Special pages (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-08 18:02 UTC by tisane2718
Modified: 2014-09-24 00:07 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to fix this bug (5.53 KB, patch)
2010-06-16 19:10 UTC, tisane2718
Details
Finds a nonblank page in one try. (4.38 KB, patch)
2010-06-16 21:17 UTC, tisane2718
Details

Description tisane2718 2010-06-08 18:02:43 UTC
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.
Comment 1 tisane2718 2010-06-16 19:10:12 UTC
Created attachment 7477 [details]
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;
	}
}
Comment 2 tisane2718 2010-06-16 19:55:06 UTC
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.
Comment 3 Platonides 2010-06-16 19:57:15 UTC
You could JOIN revision ON page_latest = rev_id and check rev_len > 0
Comment 4 tisane2718 2010-06-16 21:17:33 UTC
Created attachment 7478 [details]
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.
Comment 5 Platonides 2010-06-17 10:56:03 UTC
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.
Comment 6 p858snake 2011-04-30 00:09:38 UTC
*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*
Comment 7 Sumana Harihareswara 2011-11-10 05:56:58 UTC
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!
Comment 8 Andre Klapper 2013-01-09 13:28:54 UTC
(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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links