// Check we added the last chunk:
if ( $this->mParams['offset'] + $chunkSize == $this->mParams['filesize'] ) {
if ( $this->mParams['async'] ) {
- $progress = UploadBase::getSessionStatus( $filekey );
+ $progress = UploadBase::getSessionStatus( $this->getUser(), $filekey );
if ( $progress && $progress['result'] === 'Poll' ) {
$this->dieUsage( "Chunk assembly already in progress.", 'stashfailed' );
}
UploadBase::setSessionStatus(
+ $this->getUser(),
$filekey,
array( 'result' => 'Poll',
'stage' => 'queued', 'status' => Status::newGood() )
// Status report for "upload to stash"/"upload from stash"
if ( $this->mParams['filekey'] && $this->mParams['checkstatus'] ) {
- $progress = UploadBase::getSessionStatus( $this->mParams['filekey'] );
+ $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
if ( !$progress ) {
$this->dieUsage( 'No result in status data', 'missingresult' );
} elseif ( !$progress['status']->isGood() ) {
// No errors, no warnings: do the upload
if ( $this->mParams['async'] ) {
- $progress = UploadBase::getSessionStatus( $this->mParams['filekey'] );
+ $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
if ( $progress && $progress['result'] === 'Poll' ) {
$this->dieUsage( "Upload from stash already in progress.", 'publishfailed' );
}
UploadBase::setSessionStatus(
+ $this->getUser(),
$this->mParams['filekey'],
array( 'result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood() )
);
public function run() {
$scope = RequestContext::importScopedSession( $this->params['session'] );
$context = RequestContext::getMain();
+ $user = $context->getUser();
try {
- $user = $context->getUser();
if ( !$user->isLoggedIn() ) {
$this->setLastError( "Could not load the author user from session." );
return false;
}
- if ( count( $_SESSION ) === 0 ) {
- // Empty session probably indicates that we didn't associate
- // with the session correctly. Note that being able to load
- // the user does not necessarily mean the session was loaded.
- // Most likely cause by suhosin.session.encrypt = On.
- $this->setLastError( "Error associating with user session. " .
- "Try setting suhosin.session.encrypt = Off" );
-
- return false;
- }
-
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array( 'result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood() )
);
$status = $upload->concatenateChunks();
if ( !$status->isGood() ) {
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array( 'result' => 'Failure', 'stage' => 'assembling', 'status' => $status )
);
// Cache the info so the user doesn't have to wait forever to get the final info
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array(
'result' => 'Success',
);
} catch ( MWException $e ) {
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array(
'result' => 'Failure',
public function run() {
$scope = RequestContext::importScopedSession( $this->params['session'] );
$context = RequestContext::getMain();
+ $user = $context->getUser();
try {
- $user = $context->getUser();
if ( !$user->isLoggedIn() ) {
$this->setLastError( "Could not load the author user from session." );
return false;
}
- if ( count( $_SESSION ) === 0 ) {
- // Empty session probably indicates that we didn't associate
- // with the session correctly. Note that being able to load
- // the user does not necessarily mean the session was loaded.
- // Most likely cause by suhosin.session.encrypt = On.
- $this->setLastError( "Error associating with user session. " .
- "Try setting suhosin.session.encrypt = Off" );
-
- return false;
- }
-
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array( 'result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood() )
);
$status = Status::newFatal( 'verification-error' );
$status->value = array( 'verification' => $verification );
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status )
);
);
if ( !$status->isGood() ) {
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status )
);
// Cache the info so the user doesn't have to wait forever to get the final info
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array(
'result' => 'Success',
);
} catch ( MWException $e ) {
UploadBase::setSessionStatus(
+ $user,
$this->params['filekey'],
array(
'result' => 'Failure',
'contexttitle',
60,
$title,
- array( 'autofocus' => true )
+ array( 'autofocus' => true, 'class' => 'mw-ui-input-inline' )
) . '</p>';
$form .= '<p>' . Xml::label(
$this->msg( 'expand_templates_input' )->text(),
const WINDOWS_NONASCII_FILENAME = 13;
const FILENAME_TOO_LONG = 14;
- const SESSION_STATUS_KEY = 'wsUploadStatusData';
-
/**
* @param int $error
* @return string
}
/**
- * Get the current status of a chunked upload (used for polling).
- * The status will be read from the *current* user session.
+ * Get the current status of a chunked upload (used for polling)
+ *
+ * The value will be read from cache.
+ *
+ * @param User $user
* @param string $statusKey
* @return Status[]|bool
*/
- public static function getSessionStatus( $statusKey ) {
- return isset( $_SESSION[self::SESSION_STATUS_KEY][$statusKey] )
- ? $_SESSION[self::SESSION_STATUS_KEY][$statusKey]
- : false;
+ public static function getSessionStatus( User $user, $statusKey ) {
+ $key = wfMemcKey( 'uploadstatus', $user->getId() ?: md5( $user->getName() ), $statusKey );
+
+ return wfGetCache( CACHE_ANYTHING )->get( $key );
}
/**
- * Set the current status of a chunked upload (used for polling).
- * The status will be stored in the *current* user session.
+ * Set the current status of a chunked upload (used for polling)
+ *
+ * The value will be set in cache for 1 day
+ *
+ * @param User $user
* @param string $statusKey
* @param array|bool $value
* @return void
*/
- public static function setSessionStatus( $statusKey, $value ) {
+ public static function setSessionStatus( User $user, $statusKey, $value ) {
+ $key = wfMemcKey( 'uploadstatus', $user->getId() ?: md5( $user->getName() ), $statusKey );
+
+ $cache = wfGetCache( CACHE_ANYTHING );
if ( $value === false ) {
- unset( $_SESSION[self::SESSION_STATUS_KEY][$statusKey] );
+ $cache->delete( $key );
} else {
- $_SESSION[self::SESSION_STATUS_KEY][$statusKey] = $value;
+ $cache->set( $key, $value, 86400 );
}
}
}
parent::__construct();
$this->mDescription = 'Find registered files with no corresponding file.';
- $this->addOption( 'start', 'Starting file name', false, true );
+ $this->addOption( 'start', 'Start after this file name', false, true );
$this->addOption( 'mtimeafter', 'Only include files changed since this time', false, true );
$this->addOption( 'mtimebefore', 'Only includes files changed before this time', false, true );
$this->setBatchSize( 300 );
$mtime1 = $dbr->timestampOrNull( $this->getOption( 'mtimeafter', null ) );
$mtime2 = $dbr->timestampOrNull( $this->getOption( 'mtimebefore', null ) );
- $joinTables = array( 'image' );
- $joinConds = array( 'image' => array( 'INNER JOIN', 'img_name = page_title' ) );
+ $joinTables = array();
+ $joinConds = array();
if ( $mtime1 || $mtime2 ) {
+ $joinTables[] = 'page';
+ $joinConds['page'] = array( 'INNER JOIN',
+ array( 'page_title = img_name', 'page_namespace' => NS_FILE ) );
$joinTables[] = 'logging';
$on = array( 'log_page = page_id', 'log_type' => array( 'upload', 'move', 'delete' ) );
if ( $mtime1 ) {
do {
$res = $dbr->select(
- array_merge( array( 'page' ), $joinTables ),
+ array_merge( array( 'image' ), $joinTables ),
array( 'name' => 'img_name' ),
- array( 'page_namespace' => NS_FILE,
- "page_title >= " . $dbr->addQuotes( $lastName ) ),
+ array( "img_name > " . $dbr->addQuotes( $lastName ) ),
__METHOD__,
// DISTINCT causes a pointless filesort
array( 'ORDER BY' => 'name', 'GROUP BY' => 'name',