User:Tisane/Sandbox/Archive 1

Critiques, etc.
#.$rclimit."&rcstart=".$rcstart."&rcprop=title|timestamp|ids&rcdir=newer&format=txt
 * http://en.wikipedia.org/w/api.php?action=query&list=allpages&apfrom=Criticism_of&aplimit=500
 * http://en.wikipedia.org/w/api.php?action=query&list=allpages&apfrom=Critique_of&aplimit=500
 * http://en.wikipedia.org/w/api.php?action=query&list=allpages&apfrom=Controversies&aplimit=500
 * http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctype=new&rclimit="
 * http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rclimit=10&rcdir=newer
 * http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvstartid=351517760&rvprop=ids|flags|timestamp|user|comment|content&rvlimit=1&pageids=5871244
 * http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvstartid=351810501&rvprop=ids|flags|timestamp|user|comment|content&rvlimit=1&pageids=5871244
 * http://en.wikipedia.org/w/index.php?title=Washington_wine&action=historysubmit&diff=351810501&oldid=351517760
 * http://en.wikipedia.org/w/api.php
 * http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=rss
 * http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=atom
 * irc://irc.wikimedia.org/en.wikipedia
 * http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:MediaWiki%20websites&cmlimit=500&cmprop=title
 * http://en.wikipedia.org/w/api.php?action=query&prop=revisions&revids=351517760&rvprop=ids|flags|timestamp|user|comment|content

Dump
 − Wikipedia http://en.wikipedia.org/wiki/Main_Page MediaWiki 1.16wmf4 first-letter − Media Special  Talk User User talk Wikipedia Wikipedia talk File File talk MediaWiki MediaWiki talk Template Template talk Help <namespace key="13" case="first-letter">Help talk <namespace key="14" case="first-letter">Category <namespace key="15" case="first-letter">Category talk <namespace key="100" case="first-letter">Portal <namespace key="101" case="first-letter">Portal talk <namespace key="108" case="first-letter">Book <namespace key="109" case="first-letter">Book talk − User:Tisane/Sandbox/C <id>27368944</id> − <id>362361573</id> 2010-05-16T01:50:38Z − Tisane <id>11664850</id> <text xml:space="preserve">Test2

API
<?xml version="1.0"?> <page pageid="27368944" ns="2" title="User:Tisane/Sandbox/C"> <rev revid="362361573" parentid="362361512" user="Tisane" timestamp="2010-05-16T01:50:38Z" xml:space="preserve">Test2

$myArticle=Article::newFromID($parser->getTitle->getArticleID); $myText=$myArticle->getContent;

$title->touchLinks; $title->invalidateCache; $title->purgeSquid; $myArticle=Article::newFromID($parser->getTitle->getArticleID); $myArticle->onArticleDelete( $title ); $myArticle->onArticleEdit($title);

if ($blanking_user->getOption( 'watchunblank' )){ $editPage->watchthis=true; }

CREATE TABLE objectcache LIKE rpedorg_onegrok.objectcache
 * find ./ -name ".svn" | xargs rm -Rf
 * tar cvzf alldocs.tar.gz *.doc
 * tar xzvf filename.tgz -C /mnt/sda1

Integration SQL
I've been pondering whether it would be best to have some giant shared global table (e.g. Extension:Integration/Global table) with rows for each page on each wiki, or just have each wiki access the other wikis' pages. The disadvantage of the global table is that it duplicates the functionality of the page table (and blanked_page table, if PWD is used). But the problem with relying on blanked_page is that if there's, say, a wiki farm with 100 wikis and there needs to be a change to the blanked_page schema, then all of those wikis need to be changed. I guess that can be done easily enough with a script, though.

CREATE INDEX iwl_from ON iwlinks (iwl_from, iwl_prefix, iwl_title); CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);

Wolf

 * The elevator to greatness is out of order. Use the stairs!
 * They want you to fail because they don't want to be alone
 * Why fear the unknown when you can conquer it

Quality

 * http://www.youtube.com/watch?v=fBpyichRWo0 &mdash; It's a Mistake
 * http://www.youtube.com/watch?v=swQi4CAzmrA &mdash; Who Can It Be Now
 * http://www.youtube.com/watch?v=DNT7uZf7lew &mdash; Land Down Under
 * http://www.youtube.com/watch?v=aCca5mPMp9A &mdash; Africa
 * http://www.youtube.com/watch?v=UyG1FG3H6rY &mdash; In My Head
 * http://www.youtube.com/watch?v=anCg5EiB2AM &mdash; Valerie
 * http://www.youtube.com/watch?v=bnVUHWCynig &mdash; Halo
 * http://www.youtube.com/watch?v=bESGLojNYSo &mdash; Poker Face
 * http://www.youtube.com/watch?v=E1mU6h4Xdxc &mdash; Disturbia
 * http://www.youtube.com/watch?v=mVEG793G3N4 &mdash; Eh, Eh
 * http://www.youtube.com/watch?v=9YbLv5W4-X8 &mdash; Eh, Eh remix
 * http://www.youtube.com/watch?v=qrO4YZeyl0I &mdash; Bad Romance
 * http://www.youtube.com/watch?v=QR_qa3Ohwls &mdash; Your Love is My Drug
 * http://www.youtube.com/watch?v=sOnqjkJTMaA &mdash; Thriller
 * http://www.youtube.com/watch?v=2Hdx9JjzDfo &mdash; Dream Weaver

Urls

 * http://svn.wikimedia.org/doc/classApiQueryBacklinks.html
 * http://svn.wikimedia.org/doc/classSquidUpdate.html
 * http://svn.wikimedia.org/doc/classParserOutput.html
 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/InterwikiIntegration/
 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/PureWikiDeletion/
 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/maintenance/tables.sql?view=markup

Sigs
&lt;B&gt;&#91;&#91;User:Tisanet&#124;Tisane&#93;&#93;&lt;/B&gt; &lt;sup&gt;&#91;&#91;User talk:Tisane&#124;talk&#93;&#93;&lt;/sup&gt;/&lt;sub&gt;&#91;&#91;Special:Contributions/Tisane&#124;contribs&#93;&#93;&lt;/sub&gt; (talk) 01:49, 8 June 2010 (UTC)

Pulled from class PopulateInterwikiWatchlistTable extends SpecialPage {
/**	 * Prepare a list of titles on a user's watchlist (including talk pages) * and return an array of titles *	 * @param $user User * @return array */	function getWatchlist( $userId ) { $list= array; $dbr = wfGetDB( DB_MASTER ); $res = $dbr->select(			'watchlist',			'*',			array( 'wl_user' => $userId, ),			__METHOD__		); if( $res->numRows > 0 ) { while( $row = $res->fetchObject ) { $title = Title::makeTitle( $row->wl_namespace, $row->wl_title ); $list[] = $title; }			$res->free; }		return $list; }

A section of code that's about to be revamped
/** * A special page that populates the Interwiki watchlist table. */ class PopulateInterwikiWatchlistTable extends SpecialPage { function __construct { parent::__construct( 'PopulateInterwikiWatchlistTable', 'integration' ); wfLoadExtensionMessages( 'InterwikiIntegration' ); }	function execute( $par ) { global $wgInterwikiIntegrationPrefix, $wgOut; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); $dbw->delete ( 'integration_watchlist', '*' ); $dbList = array_unique ( $wgInterwikiIntegrationPrefix ); foreach ( $dbList as $thisDb ) { $thisDbr = wfGetDB( DB_SLAVE, array, $thisDb ); $userRes = $thisDbr->select(				'user',				'*'			); if( $userRes->numRows > 0 ) { while( $row = $userRes->fetchObject ) { $userId = $row->user_id; $watchlistRes = $thisDbr->select(						'watchlist',						'*',						array( 'wl_user' => $userId )					);					if( $watchlistRes->numRows > 0 ) { while( $row = $watchlistRes->fetchObject ) { $dbw->insert (								'integration_watchlist',								array( 'integration_wl_user' 	 => $userId, 'integration_wl_db'       => $thisDb, 'integration_wl_namespace' => $row->wl_namespace, 'integration_wl_title'	 => $row->wl_title )							);						}					}				}			}		}		$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); $wgOut->addWikiMsg( 'interwikiwatchlist-setuptext' ); return; } }

Another soon-to-be-revamped
$dbw->insert (						'integration_recentchanges',						array( 'integration_rc_local_id'		=> $row->rc_id, 'integration_wl_db' 		=> $thisDb, 'integration_rc_timestamp'	=> $row->rc_timestamp, 'integration_rc_cur_time'	 	=> $row->rc_cur_time, 'integration_rc_user'		=> $row->rc_user, 'integration_rc_user_text'	=> $row->rc_user_text, 'integration_rc_namespace'	=> $row->rc_namespace, 'integration_rc_title'		=> $row->rc_title, 'integration_rc_comment'		=> $row->rc_comment, 'integration_rc_minor'		=> $row->rc_minor, 'integration_rc_bot'		=> $row->rc_bot, 'integration_rc_new'		=> $row->rc_new, 'integration_rc_cur_id'		=> $row->rc_cur_id, 'integration_rc_this_oldid'	=> $row->rc_this_oldid, 'integration_rc_last_oldid'	=> $row->rc_last_oldid, 'integration_rc_type'		=> $row->rc_type, 'integration_rc_moved_to_ns'	=> $row->rc_moved_to_ns, 'integration_rc_moved_to_title'	=> $row->rc_moved_to_title, 'integration_rc_patrolled'	=> $row->rc_patrolled, 'integration_rc_ip'		=> $row->rc_ip, 'integration_rc_old_len'		=> $row->rc_old_len, 'integration_rc_new_len'		=> $row->rc_new_len, 'integration_rc_deleted'		=> $row->rc_deleted, 'integration_rc_logid'		=> $row->rc_logid, 'integration_rc_log_type'		=> $row->rc_log_type, 'integration_rc_log_action'	=> $row->rc_log_action, 'integration_rc_params'		=> $row->rc_params )					);

Links

 * http://wiki.developers.facebook.com/

Getting to the mysql prompt

 * mysql -u [username] -p
 * mysql -u DBUSERNAME -h DBSERVER -p DBNAME
 * QUIT (or \q
 * mw:Extension_talk:CentralAuth

More code about to be scrapped
<?php

/** * Special page to direct the user to a random page * * @ingroup SpecialPage * @author Rob Church <robchur@gmail.com>, Ilmari Karonen * @license GNU General Public Licence 2.0 or later */ class RandomPage extends SpecialPage { private $namespaces; // namespaces to select pages from protected $isRedir = false; // should the result be a redirect? protected $extra = array; // Extra SQL statements

public function __construct( $name = 'Randompage' ){ global $wgContentNamespaces; $this->namespaces = $wgContentNamespaces; parent::__construct( $name ); }

public function getNamespaces { return $this->namespaces; }

public function setNamespace ( $ns ) { if( !$ns || $ns < NS_MAIN ) $ns = NS_MAIN; $this->namespaces = array( $ns ); }

// select redirects instead of normal pages? public function isRedirect { return $this->isRedir; }

/**	 * Go to a random page * @param $excludeBlank If true, continue picking random pages until a	 * non-blank page is found or the * @param $attempts Number of attempts to find a non-blank page before * giving up	 */ public function execute( $par, $excludeBlank = false, $attempts = 1000 ) { global $wgOut, $wgContLang, $wgRequest;

if ($par) { $this->setNamespace( $wgContLang->getNsIndex( $par ) ); }

$title = $this->getRandomTitle( $excludeBlank, $attempts );

if( is_null( $title ) ) { $this->setHeaders; $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages', 				$this->getNsList, count( $this->namespaces ) ); return; }		if ( $title === false ) { $this->setHeaders; $wgOut->addWikiMsg( strtolower( $this->mName ) .				'-nononblankpages', $this->getNsList,				count( $this->namespaces ), $attempts ); return; }

$redirectParam = $this->isRedirect ? array( 'redirect' => 'no' ) : array; $query = array_merge( $wgRequest->getValues, $redirectParam ); unset( $query['title'] ); $wgOut->redirect( $title->getFullUrl( $query ) ); }

/**	 * Get a comma-delimited list of namespaces we don't have * any pages in	 * @return String */	private function getNsList { global $wgContLang; $nsNames = array; foreach( $this->namespaces as $n ) { if( $n === NS_MAIN ) $nsNames[] = wfMsgForContent( 'blanknamespace' ); else $nsNames[] = $wgContLang->getNsText( $n ); }		return $wgContLang->commaList( $nsNames ); }

/**	 * Choose a random title. * @return Title object (or null if nothing to choose from, or false if	 * pages were found but they were all blank and $excludeBlank is true	 * @param $excludeBlank If true, continue picking random pages until a	 * non-blank page is found or a certain number of attempts have been made	 * to find a non-blank page	 * @param $attempts Number of attempts to find a suitable page before	 * giving up	 */	public function getRandomTitle( $excludeBlank = false, $attempts = 1000 ) {		$randstr = wfRandom;		$title = null;		if ( !wfRunHooks( 'SpecialRandomGetRandomTitle', array( &$randstr, &$this->isRedir, &$this->namespaces, &$this->extra, &$title, &$excludeBlank, &$attempts ) ) ) {			return $title;		}		$dbr = wfGetDB( DB_SLAVE );		/* Give up after a certain number of attempts to find a suitable		 * page (i.e. non-blank, if applicable), because some wikis, or		 * some namespaces, may have few or no suitable pages.		 */		while ( $attempts > 0 ) {			$row = $this->selectRandomPageFromDB( $randstr );			/* 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 ) { if ( !$excludeBlank					|| Revision::loadFromPageId( $dbr, $row->page_id )->getRawText !== '') { return Title::makeTitleSafe( $row->page_namespace, $row->page_title ); } else { $randstr = wfRandom; }			} else { return null; }			$attempts--; }		return false; }

private function selectRandomPageFromDB( $randstr ) { global $wgExtraRandompageSQL; $dbr = wfGetDB( DB_SLAVE );

$use_index = $dbr->useIndexClause( 'page_random' ); $page = $dbr->tableName( 'page' );

$ns = implode( ",", $this->namespaces ); $redirect = $this->isRedirect ? 1 : 0;		if ( $wgExtraRandompageSQL ) { $this->extra[] = $wgExtraRandompageSQL; }		if ( $this->addExtraSQL ) { $this->extra[] = $this->addExtraSQL; }		$extra = ''; if ( $this->extra ) { $extra = 'AND (' . implode( ') AND (', $this->extra ) . ')'; }		$sql = "SELECT page_title, page_namespace, page_id			FROM $page $use_index			WHERE page_namespace IN ( $ns )			AND page_is_redirect = $redirect			AND page_random >= $randstr			$extra			ORDER BY page_random";

$sql = $dbr->limitResult( $sql, 1, 0 ); $res = $dbr->query( $sql, __METHOD__ ); return $dbr->fetchObject( $res ); }

/* an alternative to $wgExtraRandompageSQL so subclasses * can add their own SQL by overriding this function * @deprecated, append to $this->extra instead */	public function addExtraSQL { return ''; } }

More
'randompage'                 => 'Random page', 'randompage-nopages'         => 'There are no pages in the following NaN namespacess: $1.', 'randompage-nononblankpages' => 'A non-blank page was not found, after $3 attempts were made to find one by randomly selecting pages from the following NaN namespacess: $1.', 'randompage-url'             => 'Special:Random', # do not translate or duplicate this message to other languages
 * 1) Random page

MOAR!!!!
foreach ( $tables as $key => $thisTable ) { str_replace( 'integration_', '', $thisTable ); $tables[$key] = $thisTable; }

And moar
$dumpQuery = $dbr->lastQuery; #$wgOut->addWikiText ( $dumpQuery ); echo $dumpQuery; die;

Still moar
/**	 * Add newly watched articles to integration_watchlist */	public static function InterwikiIntegrationWatchArticleComplete( &$user, &$article ) { global $wgDBname; $title = $article->getTitle; if ( $title->isTalkPage ) { $subjectNamespace = $title->getSubjectPage->getNamespace; $talkNamespace = $title->getNamespace; } else { $subjectNamespace = $title->getNamespace; $talkNamespace = $title->getTalkPage->getNamespace; }		$DBkey = $title->getDBkey; $dbw = wfGetDB( DB_MASTER ); $dbw->insert( 'integration_watchlist',		 array( 'integration_wl_user' => $user->getId, 'integration_wl_db' => $wgDBname, 'integration_wl_namespace' => $subjectNamespace, 'integration_wl_title' => $DBkey ) );		$dbw->insert( 'integration_watchlist',		 array( 'integration_wl_user' => $user->getId, 'integration_wl_db' => $wgDBname, 'integration_wl_namespace' => $talkNamespace, 'integration_wl_title' => $DBkey ) );		return true; }	/**	 * Remove newly unwatched articles from integration_watchlist */	public static function InterwikiIntegrationUnwatchArticleComplete ( &$user, &$article ) { global $wgDBname; $title = $article->getTitle; if ( $title->isTalkPage ) { $subjectNamespace = $title->getSubjectPage->getNamespace; $talkNamespace = $title->getNamespace; } else { $subjectNamespace = $title->getNamespace; $talkNamespace = $title->getTalkPage->getNamespace; }		$DBkey = $title->getDBkey; $dbw = wfGetDB( DB_MASTER ); $dbw->delete( 'integration_watchlist',		 array( 'integration_wl_user' => $user->getId, 'integration_wl_db' => $wgDBname, 'integration_wl_namespace' => $subjectNamespace, 'integration_wl_title' => $DBkey ) );		$dbw->insert( 'integration_watchlist',		 array( 'integration_wl_user' => $user->getId, 'integration_wl_db' => $wgDBname, 'integration_wl_namespace' => $talkNamespace, 'integration_wl_title' => $DBkey ) );		return true; }

Even moar
&& $rc->mAttribs['integration_page_db'] == $rc->mAttribs['integration_rc_db']