Code Duplication    Length = 20-22 lines in 2 locations

includes/upload/UploadFromStash.php 1 location

@@ 47-68 (lines=22) @@
44
	 * @param UploadStash|bool $stash Default: false
45
	 * @param FileRepo|bool $repo Default: false
46
	 */
47
	public function __construct( $user = false, $stash = false, $repo = false ) {
48
		// user object. sometimes this won't exist, as when running from cron.
49
		$this->user = $user;
50
51
		if ( $repo ) {
52
			$this->repo = $repo;
53
		} else {
54
			$this->repo = RepoGroup::singleton()->getLocalRepo();
55
		}
56
57
		if ( $stash ) {
58
			$this->stash = $stash;
59
		} else {
60
			if ( $user ) {
61
				wfDebug( __METHOD__ . " creating new UploadStash instance for " . $user->getId() . "\n" );
62
			} else {
63
				wfDebug( __METHOD__ . " creating new UploadStash instance with no user\n" );
64
			}
65
66
			$this->stash = new UploadStash( $this->repo, $this->user );
67
		}
68
	}
69
70
	/**
71
	 * @param string $key

includes/upload/UploadFromChunks.php 1 location

@@ 45-64 (lines=20) @@
42
	 * @param UploadStash|bool $stash Default: false
43
	 * @param FileRepo|bool $repo Default: false
44
	 */
45
	public function __construct( User $user, $stash = false, $repo = false ) {
46
		$this->user = $user;
47
48
		if ( $repo ) {
49
			$this->repo = $repo;
50
		} else {
51
			$this->repo = RepoGroup::singleton()->getLocalRepo();
52
		}
53
54
		if ( $stash ) {
55
			$this->stash = $stash;
56
		} else {
57
			if ( $user ) {
58
				wfDebug( __METHOD__ . " creating new UploadFromChunks instance for " . $user->getId() . "\n" );
59
			} else {
60
				wfDebug( __METHOD__ . " creating new UploadFromChunks instance with no user\n" );
61
			}
62
			$this->stash = new UploadStash( $this->repo, $this->user );
63
		}
64
	}
65
66
	/**
67
	 * Calls the parent doStashFile and updates the uploadsession table to handle "chunks"