X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fupload%2FUploadStash.php;h=b7160b3ba83dc155160b2e3cd85ff05fcca586c6;hb=69ae945e8d39972a07bea89ddb64bc0189b43ac2;hp=5bcced8512c9ad45e0e2d62405f0ecb6aec3d43d;hpb=c07567928973c22f1b85969f5ba20285e59b877d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 5bcced8512..b7160b3ba8 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -73,8 +73,8 @@ class UploadStash { // fileprops cache protected $fileProps = []; - // current user info - protected $userId, $isLoggedIn; + // current user + protected $user, $userId, $isLoggedIn; /** * Represents a temporary filestore, with metadata in the database. @@ -82,15 +82,25 @@ class UploadStash { * (should replace it eventually). * * @param FileRepo $repo - * @param User $user + * @param User $user (default null) */ - public function __construct( FileRepo $repo, User $user ) { + public function __construct( FileRepo $repo, $user = null ) { // this might change based on wiki's configuration. $this->repo = $repo; - // We only need the logged in status and user id. - $this->userId = $user->getId(); - $this->isLoggedIn = $user->isLoggedIn(); + // 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(); + } } /** @@ -197,7 +207,9 @@ class UploadStash { wfDebug( __METHOD__ . " tried to stash file at '$path', but it doesn't exist\n" ); throw new UploadStashBadPathException( "path doesn't exist" ); } - $fileProps = FSFile::getPropsFromPath( $path ); + + $mwProps = new MWFileProps( MimeMagic::singleton() ); + $fileProps = $mwProps->getPropsFromPath( $path, true ); wfDebug( __METHOD__ . " stashing file at '$path'\n" ); // we will be initializing from some tmpnam files that don't have extensions.