Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 20
CRAP
0.00% covered (danger)
0.00%
0 / 1
NSOldLocalFile
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 20
552
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getRel
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getUrlRel
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 publish
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getThumbUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 thumbName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getThumbPath
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getArchiveRel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getArchiveUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getArchiveVirtualUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getThumbVirtualUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getVirtualUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFileNameStripped
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addOlds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 purgeThumbnails
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getHistory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 newFromTitle
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 newFromArchiveName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 newFromRow
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 newFromKey
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3class NSOldLocalFile extends OldLocalFile {
4
5    /**
6     *
7     * @var NSLocalFile
8     */
9    protected $internalFile = null;
10
11    public function __construct($title, $repo, $time, $archiveName) {
12        parent::__construct($title, $repo, $time, $archiveName);
13        $this->internalFile = new NSLocalFile($title, $repo);
14    }
15
16    function getRel() {
17        return 'archive/' . $this->getHashPath() .
18            $this->getFileNameStripped( $this->getArchiveName() );
19    }
20    function getUrlRel() {
21        return 'archive/' . $this->getHashPath() .
22            urlencode( $this->getFileNameStripped( $this->getArchiveName() ) );
23    }
24    function publish( $srcPath, $flags = 0, array $options = array() ) {
25        return $this->internalFile->publish( $srcPath, $flags, $options );
26    }
27    function getThumbUrl( $suffix = false ) {
28        return $this->internalFile->getArchiveThumbUrl( $this->getFileNameStripped( $this->getArchiveName() ), $suffix );
29    }
30    function thumbName( $params, $flags = 0 ) {
31        return $this->internalFile->thumbName( $params, $flags );
32    }
33    function getThumbPath( $suffix = false ) {
34        return $this->internalFile->getArchiveThumbPath( $this->getFileNameStripped( $this->getArchiveName() ), $suffix );
35    }
36    function getArchiveRel( $suffix = false ) {
37        return $this->internalFile->getArchiveRel( $suffix );
38    }
39    function getArchiveUrl( $suffix = false ) {
40        return $this->internalFile->getArchiveUrl( $suffix );
41    }
42    function getArchiveVirtualUrl( $suffix = false ) {
43        return $this->internalFile->getArchiveVirtualUrl( $suffix );
44    }
45    function getThumbVirtualUrl( $suffix = false ) {
46        return $this->internalFile->getThumbVirtualUrl( $suffix );
47    }
48    function getVirtualUrl( $suffix = false ) {
49        return $this->internalFile->getVirtualUrl( $suffix );
50    }
51    function getFileNameStripped($suffix) {
52        return $this->internalFile->getFileNameStripped( $suffix );
53    }
54    function addOlds() {
55        return $this->internalFile->addOlds();
56    }
57    function purgeThumbnails($options = array() ) {
58        return $this->internalFile->purgeThumbnails( $options );
59    }
60    /**
61     * Replaces hard coded OldLocalFile::newFromRow to use $this->repo->oldFileFromRowFactory configuration
62     * This may not be necessary in the future if LocalFile is patched to allow configuration
63    */
64    function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
65        return $this->internalFile->getHistory( $limit, $start , $end, $inc );
66    }
67
68    /** See comment above about Instantiating this class using "self" */
69
70    static function newFromTitle( $title, $repo, $time = null ) {
71        # The null default value is only here to avoid an E_STRICT
72        if( $time === null )
73            throw new MWException( __METHOD__.' got null for $time parameter' );
74        return new self( $title, $repo, $time, null );
75    }
76
77    static function newFromArchiveName( $title, $repo, $archiveName ) {
78        return new self( $title, $repo, null, $archiveName );
79    }
80
81    static function newFromRow( $row, $repo ) {
82        $title = Title::makeTitle( NS_FILE, $row->oi_name );
83        $file = new self( $title, $repo, null, $row->oi_archive_name );
84        $file->loadFromRow( $row, 'oi_' );
85        return $file;
86    }
87
88    /**
89     * Create a OldLocalFile from a SHA-1 key
90     * Do not call this except from inside a repo class.
91     *
92     * Copy & paste from OldLocalFile to fix "late-static-binding" issue
93     *
94     * @param string $sha1 Base-36 SHA-1
95     * @param LocalRepo $repo
96     * @param string|bool $timestamp MW_timestamp (optional)
97     *
98     * @return bool|OldLocalFile
99     */
100    static function newFromKey( $sha1, $repo, $timestamp = false ) {
101        $dbr = $repo->getReplicaDB();
102
103        $conds = [ 'oi_sha1' => $sha1 ];
104        if ( $timestamp ) {
105            $conds['oi_timestamp'] = $dbr->timestamp( $timestamp );
106        }
107
108        $fileQuery = static::getQueryInfo();
109        $row = $dbr->selectRow(
110            $fileQuery['tables'], $fileQuery['fields'], $conds, __METHOD__, [], $fileQuery['joins']
111        );
112        if ( $row ) {
113            return static::newFromRow( $row, $repo );
114        } else {
115            return false;
116        }
117    }
118}