// fileprops cache
protected $fileProps = [];
- // current user
- protected $user, $userId, $isLoggedIn;
+ // current user info
+ protected $userId, $isLoggedIn;
/**
* Represents a temporary filestore, with metadata in the database.
* (should replace it eventually).
*
* @param FileRepo $repo
- * @param User $user (default null)
+ * @param User $user
*/
- public function __construct( FileRepo $repo, $user = null ) {
+ public function __construct( FileRepo $repo, User $user ) {
// this might change based on wiki's configuration.
$this->repo = $repo;
- // if a user was passed, use it. otherwise, attempt to use the global.
- // this keeps FileRepo from breaking when it creates an UploadStash object
- if ( $user ) {
- $this->user = $user;
- } else {
- global $wgUser;
- $this->user = $wgUser;
- }
-
- if ( is_object( $this->user ) ) {
- $this->userId = $this->user->getId();
- $this->isLoggedIn = $this->user->isLoggedIn();
- }
+ // We only need the logged in status and user id.
+ $this->userId = $user->getId();
+ $this->isLoggedIn = $user->isLoggedIn();
}
/**
// this could be done some other, more direct/efficient way, but using
// UploadStash's own methods means it's less likely to fall accidentally
// out-of-date someday
- $stash = new UploadStash( $repo );
+ $stash = new UploadStash( $repo, new User() );
$i = 0;
foreach ( $keys as $key ) {
* @todo give this test a real name explaining what is being tested here
*/
public function testBug29408() {
- $this->setMwGlobals( 'wgUser', self::$users['uploader']->getUser() );
-
$repo = RepoGroup::singleton()->getLocalRepo();
- $stash = new UploadStash( $repo );
+ $stash = new UploadStash( $repo, self::$users['uploader']->getUser() );
// Throws exception caught by PHPUnit on failure
$file = $stash->stashFile( $this->bug29408File );