// @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
// We should instead work with the Revision object when we need it...
- $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
+ $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER, $this->getContext()->getUser() ); // Loads if user is allowed
$this->mRevIdFetched = $this->mRevision->getId();
wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
$title = Title::newFromText( $preload );
# Check for existence to avoid getting MediaWiki:Noarticletext
- if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
+ if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
return '';
}
if ( $page->isRedirect() ) {
$title = $page->getRedirectTarget();
# Same as before
- if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
+ if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
return '';
}
$page = WikiPage::factory( $title );
if ( $new ) {
// Late check for create permission, just in case *PARANOIA*
- if ( !$this->mTitle->userCan( 'create' ) ) {
+ if ( !$this->mTitle->userCan( 'create', $wgUser ) ) {
$status->fatal( 'nocreatetext' );
$status->value = self::AS_NO_CREATE_PERMISSION;
wfDebug( __METHOD__ . ": no create permission\n" );
if ( $revision ) {
// Let sysop know that this will make private content public if saved
- if ( !$revision->userCan( Revision::DELETED_TEXT ) ) {
+ if ( !$revision->userCan( Revision::DELETED_TEXT, $wgUser ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
} elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
* - name: [optional], default: 'namespace'
* @return string HTML code to select a namespace.
*/
- public static function namespaceSelector( Array $params = array(), Array $selectAttribs = array() ) {
+ public static function namespaceSelector( array $params = array(), array $selectAttribs = array() ) {
global $wgContLang;
ksort( $selectAttribs );
* @param $namespace Integer
* @param $dbkeys Array
*/
- protected function invalidatePages( $namespace, Array $dbkeys ) {
+ protected function invalidatePages( $namespace, array $dbkeys ) {
if ( !count( $dbkeys ) ) {
return;
}
$this->mEffectiveGroups = null;
$this->mImplicitGroups = null;
$this->mOptions = null;
+ $this->mEditCount = null;
if ( $reloadFrom ) {
$this->mLoadedItems = array();
$titles = Title::newFromRedirectArray(
Revision::newFromTitle(
$oldTitle, false, Revision::READ_LATEST
- )->getText( Revision::FOR_THIS_USER )
+ )->getText( Revision::FOR_THIS_USER, $user )
);
// array_shift( $titles );
//
// b) the DBO_TRX flag is not set. Explicit transactions should always be properly
// started and comitted.
- wfWarn( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
- " performing implicit commit!" );
- } else {
- if ( $wgDebugDBTransactions ) {
- wfDebug( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
- " performing implicit commit!\n" );
- }
+ /*wfWarn( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
+ " performing implicit commit!" );*/
+ } elseif ( $wgDebugDBTransactions ) {
+ wfDebug( "$fname: Transaction already in progress (from {$this->mTrxFname}), " .
+ " performing implicit commit!\n" );
}
$this->doCommit( $fname );
return false;
}
if ( $this->mOldRev ) {
- $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER );
+ $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
if ( $this->mOldtext === false ) {
return false;
}
}
if ( $this->mNewRev ) {
- $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
+ $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
if ( $this->mNewtext === false ) {
return false;
}
if ( !$this->loadRevisionData() ) {
return false;
}
- $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
+ $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER, $this->getUser() );
return true;
}
}
return $status;
}
+ /**
+ * @see FileJournal::doGetCurrentPosition()
+ * @return integer|false
+ */
+ protected function doGetCurrentPosition() {
+ $dbw = $this->getMasterDB();
+
+ return $dbw->selectField( 'filejournal', 'MAX(fj_id)',
+ array( 'fj_backend' => $this->backend ),
+ __METHOD__
+ );
+ }
+
/**
* @see FileJournal::doGetChangeEntries()
* @return Array
*/
abstract protected function doLogChangeBatch( array $entries, $batchId );
+ /**
+ * Get the position ID of the latest journal entry
+ *
+ * @return integer|false
+ */
+ final public function getCurrentPosition() {
+ return $this->doGetCurrentPosition();
+ }
+
+ /**
+ * @see FileJournal::getCurrentPosition()
+ * @return integer|false
+ */
+ abstract protected function doGetCurrentPosition();
+
/**
* Get an array of file change log entries.
* A starting change ID and/or limit can be specified.
*/
class NullFileJournal extends FileJournal {
/**
- * @see FileJournal::logChangeBatch()
+ * @see FileJournal::doLogChangeBatch()
* @param $entries array
* @param $batchId string
* @return Status
return Status::newGood();
}
+ /**
+ * @see FileJournal::doGetCurrentPosition()
+ * @return integer|false
+ */
+ protected function doGetCurrentPosition() {
+ return false;
+ }
+
/**
* @see FileJournal::doGetChangeEntries()
* @return Array
}
/**
- * @see FileJournal::purgeOldLogs()
+ * @see FileJournal::doPurgeOldLogs()
* @return Status
*/
protected function doPurgeOldLogs() {
* Note that callback functions will receive this object as
* first parameter.
*/
- public function addExtensionUpdate( Array $update ) {
+ public function addExtensionUpdate( array $update ) {
$this->extensionUpdates[] = $update;
}
if( $t->isKnown() ) {
$messageName = 'searchmenu-exists';
- } elseif( $t->userCan( 'create' ) ) {
+ } elseif( $t->userCan( 'create', $this->getUser() ) ) {
$messageName = 'searchmenu-new';
} else {
$messageName = 'searchmenu-new-nocreate';
//If page content is not readable, just return the title.
//This is not quite safe, but better than showing excerpts from non-readable pages
//Note that hiding the entry entirely would screw up paging.
- if( !$t->userCan( 'read' ) ) {
+ if( !$t->userCan( 'read', $this->getUser() ) ) {
wfProfileOut( __METHOD__ );
return "<li>{$link}</li>\n";
}
* Constructor.
* @param $options array Options for script.
*/
- public function __construct( Array $options ) {
+ public function __construct( array $options ) {
if ( isset( $options['help'] ) ) {
echo $this->help();
exit(1);
* @param $options array Options for script.
* @param $extension string The extension name (or names).
*/
- public function __construct( Array $options, $extension ) {
+ public function __construct( array $options, $extension ) {
if ( isset( $options['help'] ) ) {
echo $this->help();
exit(1);
parent::__construct();
$this->mDescription = "Sync one file backend with another using the journal";
$this->addOption( 'src', 'Name of backend to sync from', true, true );
- $this->addOption( 'dst', 'Name of destination backend to sync', true, true );
+ $this->addOption( 'dst', 'Name of destination backend to sync', false, true );
$this->addOption( 'start', 'Starting journal ID', false, true );
$this->addOption( 'end', 'Ending journal ID', false, true );
$this->addOption( 'posdir', 'Directory to read/record journal positions', false, true );
+ $this->addOption( 'posdump', 'Just dump current journal position into the position dir.' );
$this->addOption( 'verbose', 'Verbose mode', false, false, 'v' );
$this->setBatchSize( 50 );
}
public function execute() {
$src = FileBackendGroup::singleton()->get( $this->getOption( 'src' ) );
- $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) );
$posDir = $this->getOption( 'posdir' );
$posFile = $posDir ? $posDir . '/' . wfWikiID() : false;
+ if ( $this->hasOption( 'posdump' ) ) {
+ // Just dump the current position into the specified position dir
+ if ( !$this->hasOption( 'posdir' ) ) {
+ $this->error( "Param posdir required!", 1 );
+ }
+ $id = (int)$src->getJournal()->getCurrentPosition(); // default to 0
+ $this->output( "Current journal position is $id.\n" );
+ if ( file_put_contents( $posFile, $id, LOCK_EX ) !== false ) {
+ $this->output( "Saved journal position file.\n" );
+ } else {
+ $this->output( "Could not save journal position file.\n" );
+ }
+ if ( $this->isQuiet() ) {
+ print $id; // give a single machine-readable number
+ }
+ return;
+ }
+
+ if ( !$this->hasOption( 'dst' ) ) {
+ $this->error( "Param dst required!", 1 );
+ }
+ $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) );
+
$start = $this->getOption( 'start', 0 );
if ( !$start && $posFile && is_dir( $posDir ) ) {
$start = is_file( $posFile )
==Section 1==
!! end
+###
+### <includeonly> and <noinclude> in attributes
+###
+!!test
+1. includeonly around the entire attribute
+!!input
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!!result
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr key
+!!input
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!!result
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in html attr value
+!!input
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!!result
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+4. includeonly in part of an attr value
+!!input
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!!result
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
###
### Testing parsing of templates where a template arg
### has the same name as the template itself.
* or list the tables under testing in $this->tablesUsed, or override the
* needsDB() method.
*/
- protected function assertSelect( $table, $fields, $condition, Array $expectedRows ) {
+ protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
if ( !$this->needsDB() ) {
throw new MWException( 'When testing database state, the test cases\'s needDB()' .
' method should return true. Use @group Database or $this->tablesUsed.');
#@todo: test recursive, too!
- protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, Array $expectedRows ) {
+ protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
$update = new LinksUpdate( $title, $parserOutput );
$update->doUpdate();
}
- protected function doApiRequest( Array $params, Array $session = null, $appendModule = false, User $user = null ) {
+ protected function doApiRequest( array $params, array $session = null, $appendModule = false, User $user = null ) {
global $wgRequest, $wgUser;
if ( is_null( $session ) ) {
* @param $session Array|null: session array
* @param $user User|null A User object for the context
*/
- protected function doApiRequestWithToken( Array $params, Array $session = null, User $user = null ) {
+ protected function doApiRequestWithToken( array $params, array $session = null, User $user = null ) {
global $wgRequest;
if ( $session === null ) {
}
}
- protected function doApiRequest( Array $params, Array $unused = null, $appendModule = false, User $user = null ) {
+ protected function doApiRequest( array $params, array $unused = null, $appendModule = false, User $user = null ) {
$sessionId = session_id();
session_write_close();