Index: trunk/phase3/includes/media/MediaTransformOutput.php |
— | — | @@ -86,35 +86,43 @@ |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | | - * Check if an output thumbnail file was actually made. |
| 90 | + * Check if an output thumbnail file actually exists. |
91 | 91 | * This will return false if there was an error, the |
92 | | - * thumnail is to be handled client-side only, or if |
| 92 | + * thumbnail is to be handled client-side only, or if |
93 | 93 | * transformation was deferred via TRANSFORM_LATER. |
94 | | - * |
| 94 | + * |
95 | 95 | * @return Bool |
96 | 96 | */ |
97 | 97 | public function hasFile() { |
98 | | - // If TRANSFORM_LATER, $this->path will be false |
99 | | - return ( !$this->isError() && $this->path ); |
| 98 | + // If TRANSFORM_LATER, $this->path will be false. |
| 99 | + // Note: a null path means "use the source file". |
| 100 | + return ( !$this->isError() && ( $this->path || $this->path === null ) ); |
100 | 101 | } |
101 | 102 | |
102 | 103 | /** |
103 | | - * Check if the output thumbnail file is the same as the source. |
| 104 | + * Check if the output thumbnail is the same as the source. |
104 | 105 | * This can occur if the requested width was bigger than the source. |
105 | 106 | * |
106 | 107 | * @return Bool |
107 | 108 | */ |
108 | 109 | public function fileIsSource() { |
109 | | - return ( !$this->isError() && $this->path === $this->file->getLocalRefPath() ); |
| 110 | + return ( !$this->isError() && $this->path === null ); |
110 | 111 | } |
111 | 112 | |
112 | 113 | /** |
113 | | - * Get the path of a file system copy of the thumbnail |
| 114 | + * Get the path of a file system copy of the thumbnail. |
| 115 | + * Callers should never write to this path. |
114 | 116 | * |
115 | 117 | * @return string|false Returns false if there isn't one |
116 | 118 | */ |
117 | 119 | public function getLocalCopyPath() { |
118 | | - return $this->path; |
| 120 | + if ( $this->isError() ) { |
| 121 | + return false; |
| 122 | + } elseif ( $this->path === null ) { |
| 123 | + return $this->file->getLocalRefPath(); |
| 124 | + } else { |
| 125 | + return $this->path; // may return false |
| 126 | + } |
119 | 127 | } |
120 | 128 | |
121 | 129 | /** |
— | — | @@ -124,7 +132,7 @@ |
125 | 133 | * @return Bool success |
126 | 134 | */ |
127 | 135 | public function streamFile( $headers = array() ) { |
128 | | - return $this->path && StreamFile::stream( $this->path, $headers ); |
| 136 | + return $this->path && StreamFile::stream( $this->getLocalCopyPath(), $headers ); |
129 | 137 | } |
130 | 138 | |
131 | 139 | /** |
— | — | @@ -170,13 +178,16 @@ |
171 | 179 | * @ingroup Media |
172 | 180 | */ |
173 | 181 | class ThumbnailImage extends MediaTransformOutput { |
174 | | - |
175 | 182 | /** |
| 183 | + * Get a thumbnail object from a file and parameters. |
| 184 | + * If $path is set to null, the output file is treated as a source copy. |
| 185 | + * If $path is set to false, no output file will be created. |
| 186 | + * |
176 | 187 | * @param $file File object |
177 | 188 | * @param $url String: URL path to the thumb |
178 | 189 | * @param $width Integer: file's width |
179 | 190 | * @param $height Integer: file's height |
180 | | - * @param $path String: filesystem path to the thumb |
| 191 | + * @param $path String|false|null: filesystem path to the thumb |
181 | 192 | * @param $page Integer: page number, for multipage files |
182 | 193 | * @private |
183 | 194 | */ |
Index: trunk/phase3/includes/media/Bitmap.php |
— | — | @@ -125,7 +125,6 @@ |
126 | 126 | 'srcWidth' => $image->getWidth(), |
127 | 127 | 'srcHeight' => $image->getHeight(), |
128 | 128 | 'mimeType' => $image->getMimeType(), |
129 | | - 'srcPath' => $image->getLocalRefPath(), |
130 | 129 | 'dstPath' => $dstPath, |
131 | 130 | 'dstUrl' => $dstUrl, |
132 | 131 | ); |
— | — | @@ -163,6 +162,9 @@ |
164 | 163 | return $this->getClientScalingThumbnailImage( $image, $scalerParams ); |
165 | 164 | } |
166 | 165 | |
| 166 | + # Transform functions and binaries need a FS source file |
| 167 | + $scalerParams['srcPath'] = $image->getLocalRefPath(); |
| 168 | + |
167 | 169 | # Try a hook |
168 | 170 | $mto = null; |
169 | 171 | wfRunHooks( 'BitmapHandlerTransform', array( $this, $image, &$scalerParams, &$mto ) ); |
— | — | @@ -248,7 +250,7 @@ |
249 | 251 | */ |
250 | 252 | protected function getClientScalingThumbnailImage( $image, $params ) { |
251 | 253 | return new ThumbnailImage( $image, $image->getURL(), |
252 | | - $params['clientWidth'], $params['clientHeight'], $params['srcPath'] ); |
| 254 | + $params['clientWidth'], $params['clientHeight'], null ); |
253 | 255 | } |
254 | 256 | |
255 | 257 | /** |