User:Tisane/Sandbox/Archive 1
Critiques, etc.
[edit]- 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="
#.$rclimit."&rcstart=".$rcstart."&rcprop=title|timestamp|ids&rcdir=newer&format=txt
- 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%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Ccontent&rvlimit=1&pageids=5871244
- http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvstartid=351810501&rvprop=ids%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Ccontent&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%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Ccontent
Dump
[edit]<mediawiki xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.4/ http://www.mediawiki.org/xml/export-0.4.xsd" version="0.4" xml:lang="en"> − <siteinfo> <sitename>Wikipedia</sitename> <base>http://en.wikipedia.org/wiki/Main_Page</base> <generator>MediaWiki 1.16wmf4</generator> <case>first-letter</case> − <namespaces> <namespace key="-2" case="first-letter">Media</namespace> <namespace key="-1" case="first-letter">Special</namespace> <namespace key="0" case="first-letter"/> <namespace key="1" case="first-letter">Talk</namespace> <namespace key="2" case="first-letter">User</namespace> <namespace key="3" case="first-letter">User talk</namespace> <namespace key="4" case="first-letter">Wikipedia</namespace> <namespace key="5" case="first-letter">Wikipedia talk</namespace> <namespace key="6" case="first-letter">File</namespace> <namespace key="7" case="first-letter">File talk</namespace> <namespace key="8" case="first-letter">MediaWiki</namespace> <namespace key="9" case="first-letter">MediaWiki talk</namespace> <namespace key="10" case="first-letter">Template</namespace> <namespace key="11" case="first-letter">Template talk</namespace> <namespace key="12" case="first-letter">Help</namespace> <namespace key="13" case="first-letter">Help talk</namespace> <namespace key="14" case="first-letter">Category</namespace> <namespace key="15" case="first-letter">Category talk</namespace> <namespace key="100" case="first-letter">Portal</namespace> <namespace key="101" case="first-letter">Portal talk</namespace> <namespace key="108" case="first-letter">Book</namespace> <namespace key="109" case="first-letter">Book talk</namespace> </namespaces> </siteinfo> − <page> <title>User:Tisane/Sandbox/C</title> <id>27368944</id> − <revision> <id>362361573</id> <timestamp>2010-05-16T01:50:38Z</timestamp> − <contributor> <username>Tisane</username> <id>11664850</id> </contributor> <text xml:space="preserve">Test2</text> </revision> </page> </mediawiki>
API
[edit]<?xml version="1.0"?> <api>
<query> <pages> <page pageid="27368944" ns="2" title="User:Tisane/Sandbox/C"> <revisions> <rev revid="362361573" parentid="362361512" user="Tisane" timestamp="2010-05-16T01:50:38Z" xml:space="preserve">Test2</rev> </revisions> </page> </pages> </query>
</api>
Editing $1
$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
Immigration
[edit]Integration SQL
[edit]BEGIN;
CREATE TABLE integration_page(
integration_id int UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
integration_page_id int UNSIGNED NOT NULL,
integration_page_title varchar(256) binary NOT NULL,
integration_page_namespace int NOT NULL,
integration_page_database varchar(256),
integration_page_is_blank binary(1),
integration_blank_user_id int UNSIGNED NOT NULL,
integration_blank_user_name varchar(256),
integration_blank_timestamp varbinary(14),
integration_blank_summary varchar(256),
integration_parent_id int UNSIGNED
)
CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE INDEX integration_id ON integration_page (integration_id);
CREATE INDEX integration_page_id ON integration_page (integration_page_id);
CREATE INDEX integration_page_title ON integration_page (integration_page_title);
CREATE INDEX integration_page_namespace ON integration_page (integration_page_namespace);
CREATE INDEX integration_page_database ON integration_page (integration_page_database);
CREATE INDEX integration_blank_user_id ON integration_page (integration_blank_user_id);
CREATE INDEX integration_blank_user_name ON integration_page (integration_blank_user_name);
CREATE INDEX integration_blank_timestamp ON integration_page (integration_blank_timestamp);
COMMIT;
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
[edit]- 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
[edit]- http://www.youtube.com/watch?v=fBpyichRWo0 — It's a Mistake
- http://www.youtube.com/watch?v=swQi4CAzmrA — Who Can It Be Now
- http://www.youtube.com/watch?v=DNT7uZf7lew — Land Down Under
- http://www.youtube.com/watch?v=aCca5mPMp9A — Africa
- http://www.youtube.com/watch?v=UyG1FG3H6rY — In My Head
- http://www.youtube.com/watch?v=anCg5EiB2AM — Valerie
- http://www.youtube.com/watch?v=bnVUHWCynig — Halo
- http://www.youtube.com/watch?v=bESGLojNYSo — Poker Face
- http://www.youtube.com/watch?v=E1mU6h4Xdxc — Disturbia
- http://www.youtube.com/watch?v=mVEG793G3N4 — Eh, Eh
- http://www.youtube.com/watch?v=9YbLv5W4-X8 — Eh, Eh remix
- http://www.youtube.com/watch?v=qrO4YZeyl0I — Bad Romance
- http://www.youtube.com/watch?v=QR_qa3Ohwls — Your Love is My Drug
- http://www.youtube.com/watch?v=sOnqjkJTMaA — Thriller
- http://www.youtube.com/watch?v=2Hdx9JjzDfo — Dream Weaver
Urls
[edit]- 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
[edit]<B>[[User:Tisanet|Tisane]]</B> <sup>[[User talk:Tisane|talk]]</sup>/<sub>[[Special:Contributions/Tisane|contribs]]</sub> (talk) 01:49, 8 June 2010 (UTC)
Pulled from class PopulateInterwikiWatchlistTable extends SpecialPage {
[edit]/** * 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
[edit]/**
* 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
[edit]$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
[edit]Getting to the mysql prompt
[edit]- mysql -u [username] -p
- mysql -u DBUSERNAME -h DBSERVER -p DBNAME
- QUIT (or \q
- mw:Extension_talk:CentralAuth#table_describes_.28reference.29
More code about to be scrapped
[edit]<?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
[edit]- Random page
'randompage' => 'Random page', 'randompage-nopages' => 'There are no pages in the following namespaces: $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 namespaces: $1.', 'randompage-url' => 'Special:Random', # do not translate or duplicate this message to other languages
MOAR!!!!
[edit]foreach ( $tables as $key => $thisTable ) {
str_replace( 'integration_', , $thisTable ); $tables[$key] = $thisTable; }
And moar
[edit]$dumpQuery = $dbr->lastQuery(); #$wgOut->addWikiText ( $dumpQuery ); echo $dumpQuery; die();
Still moar
[edit]/** * 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
[edit]&& $rc->mAttribs['integration_page_db'] == $rc->mAttribs['integration_rc_db']