(bug 32412) TOC links on [[Special:EditWatchlist]] now points to the fieldset
[lhc/web/wiklou.git] / includes / filerepo / FSRepo.php
1 <?php
2 /**
3 * A repository for files accessible via the local filesystem.
4 *
5 * @file
6 * @ingroup FileRepo
7 */
8
9 /**
10 * A repository for files accessible via the local filesystem. Does not support
11 * database access or registration.
12 * @ingroup FileRepo
13 */
14 class FSRepo extends FileRepo {
15 var $directory, $deletedDir, $deletedHashLevels, $fileMode;
16 var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' );
17 var $oldFileFactory = false;
18 var $pathDisclosureProtection = 'simple';
19
20 function __construct( $info ) {
21 parent::__construct( $info );
22
23 // Required settings
24 $this->directory = $info['directory'];
25 $this->url = $info['url'];
26
27 // Optional settings
28 $this->hashLevels = isset( $info['hashLevels'] ) ? $info['hashLevels'] : 2;
29 $this->deletedHashLevels = isset( $info['deletedHashLevels'] ) ?
30 $info['deletedHashLevels'] : $this->hashLevels;
31 $this->deletedDir = isset( $info['deletedDir'] ) ? $info['deletedDir'] : false;
32 $this->fileMode = isset( $info['fileMode'] ) ? $info['fileMode'] : 0644;
33 if ( isset( $info['thumbDir'] ) ) {
34 $this->thumbDir = $info['thumbDir'];
35 } else {
36 $this->thumbDir = "{$this->directory}/thumb";
37 }
38 if ( isset( $info['thumbUrl'] ) ) {
39 $this->thumbUrl = $info['thumbUrl'];
40 } else {
41 $this->thumbUrl = "{$this->url}/thumb";
42 }
43 }
44
45 /**
46 * Get the public root directory of the repository.
47 * @return string
48 */
49 function getRootDirectory() {
50 return $this->directory;
51 }
52
53 /**
54 * Get the public root URL of the repository
55 * @return string
56 */
57 function getRootUrl() {
58 return $this->url;
59 }
60
61 /**
62 * Returns true if the repository uses a multi-level directory structure
63 * @return string
64 */
65 function isHashed() {
66 return (bool)$this->hashLevels;
67 }
68
69 /**
70 * Get the local directory corresponding to one of the three basic zones
71 *
72 * @param $zone string
73 *
74 * @return string
75 */
76 function getZonePath( $zone ) {
77 switch ( $zone ) {
78 case 'public':
79 return $this->directory;
80 case 'temp':
81 return "{$this->directory}/temp";
82 case 'deleted':
83 return $this->deletedDir;
84 case 'thumb':
85 return $this->thumbDir;
86 default:
87 return false;
88 }
89 }
90
91 /**
92 * @see FileRepo::getZoneUrl()
93 *
94 * @param $zone string
95 *
96 * @return string url
97 */
98 function getZoneUrl( $zone ) {
99 switch ( $zone ) {
100 case 'public':
101 return $this->url;
102 case 'temp':
103 return "{$this->url}/temp";
104 case 'deleted':
105 return parent::getZoneUrl( $zone ); // no public URL
106 case 'thumb':
107 return $this->thumbUrl;
108 default:
109 return parent::getZoneUrl( $zone );
110 }
111 }
112
113 /**
114 * Get a URL referring to this repository, with the private mwrepo protocol.
115 * The suffix, if supplied, is considered to be unencoded, and will be
116 * URL-encoded before being returned.
117 *
118 * @param $suffix string
119 *
120 * @return string
121 */
122 function getVirtualUrl( $suffix = false ) {
123 $path = 'mwrepo://' . $this->name;
124 if ( $suffix !== false ) {
125 $path .= '/' . rawurlencode( $suffix );
126 }
127 return $path;
128 }
129
130 /**
131 * Get the local path corresponding to a virtual URL
132 *
133 * @param $url string
134 *
135 * @return string
136 */
137 function resolveVirtualUrl( $url ) {
138 if ( substr( $url, 0, 9 ) != 'mwrepo://' ) {
139 throw new MWException( __METHOD__.': unknown protocol' );
140 }
141
142 $bits = explode( '/', substr( $url, 9 ), 3 );
143 if ( count( $bits ) != 3 ) {
144 throw new MWException( __METHOD__.": invalid mwrepo URL: $url" );
145 }
146 list( $repo, $zone, $rel ) = $bits;
147 if ( $repo !== $this->name ) {
148 throw new MWException( __METHOD__.": fetching from a foreign repo is not supported" );
149 }
150 $base = $this->getZonePath( $zone );
151 if ( !$base ) {
152 throw new MWException( __METHOD__.": invalid zone: $zone" );
153 }
154 return $base . '/' . rawurldecode( $rel );
155 }
156
157 /**
158 * Store a batch of files
159 *
160 * @param $triplets Array: (src,zone,dest) triplets as per store()
161 * @param $flags Integer: bitwise combination of the following flags:
162 * self::DELETE_SOURCE Delete the source file after upload
163 * self::OVERWRITE Overwrite an existing destination file instead of failing
164 * self::OVERWRITE_SAME Overwrite the file if the destination exists and has the
165 * same contents as the source
166 * @return Status
167 */
168 function storeBatch( $triplets, $flags = 0 ) {
169 wfDebug( __METHOD__ . ': Storing ' . count( $triplets ) .
170 " triplets; flags: {$flags}\n" );
171
172 // Try creating directories
173 if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
174 return $this->newFatal( 'upload_directory_missing', $this->directory );
175 }
176 if ( !is_writable( $this->directory ) ) {
177 return $this->newFatal( 'upload_directory_read_only', $this->directory );
178 }
179
180 // Validate each triplet
181 $status = $this->newGood();
182 foreach ( $triplets as $i => $triplet ) {
183 list( $srcPath, $dstZone, $dstRel ) = $triplet;
184
185 // Resolve destination path
186 $root = $this->getZonePath( $dstZone );
187 if ( !$root ) {
188 throw new MWException( "Invalid zone: $dstZone" );
189 }
190 if ( !$this->validateFilename( $dstRel ) ) {
191 throw new MWException( 'Validation error in $dstRel' );
192 }
193 $dstPath = "$root/$dstRel";
194 $dstDir = dirname( $dstPath );
195
196 // Create destination directories for this triplet
197 if ( !is_dir( $dstDir ) ) {
198 if ( !wfMkdirParents( $dstDir, null, __METHOD__ ) ) {
199 return $this->newFatal( 'directorycreateerror', $dstDir );
200 }
201 if ( $dstZone == 'deleted' ) {
202 $this->initDeletedDir( $dstDir );
203 }
204 }
205
206 // Resolve source
207 if ( self::isVirtualUrl( $srcPath ) ) {
208 $srcPath = $triplets[$i][0] = $this->resolveVirtualUrl( $srcPath );
209 }
210 if ( !is_file( $srcPath ) ) {
211 // Make a list of files that don't exist for return to the caller
212 $status->fatal( 'filenotfound', $srcPath );
213 continue;
214 }
215
216 // Check overwriting
217 if ( !( $flags & self::OVERWRITE ) && file_exists( $dstPath ) ) {
218 if ( $flags & self::OVERWRITE_SAME ) {
219 $hashSource = sha1_file( $srcPath );
220 $hashDest = sha1_file( $dstPath );
221 if ( $hashSource != $hashDest ) {
222 $status->fatal( 'fileexistserror', $dstPath );
223 $status->failCount++;
224 }
225 } else {
226 $status->fatal( 'fileexistserror', $dstPath );
227 $status->failCount++;
228 }
229 }
230 }
231
232 // Windows does not support moving over existing files, so explicitly delete them
233 $deleteDest = wfIsWindows() && ( $flags & self::OVERWRITE );
234
235 // Abort now on failure
236 if ( !$status->ok ) {
237 return $status;
238 }
239
240 // Execute the store operation for each triplet
241 foreach ( $triplets as $i => $triplet ) {
242 list( $srcPath, $dstZone, $dstRel ) = $triplet;
243 $root = $this->getZonePath( $dstZone );
244 $dstPath = "$root/$dstRel";
245 $good = true;
246
247 if ( $flags & self::DELETE_SOURCE ) {
248 if ( $deleteDest ) {
249 unlink( $dstPath );
250 }
251 if ( !rename( $srcPath, $dstPath ) ) {
252 $status->error( 'filerenameerror', $srcPath, $dstPath );
253 $good = false;
254 }
255 } else {
256 if ( !copy( $srcPath, $dstPath ) ) {
257 $status->error( 'filecopyerror', $srcPath, $dstPath );
258 $good = false;
259 }
260 if ( !( $flags & self::SKIP_VALIDATION ) ) {
261 wfSuppressWarnings();
262 $hashSource = sha1_file( $srcPath );
263 $hashDest = sha1_file( $dstPath );
264 wfRestoreWarnings();
265
266 if ( $hashDest === false || $hashSource !== $hashDest ) {
267 wfDebug( __METHOD__ . ': File copy validation failed: ' .
268 "$srcPath ($hashSource) to $dstPath ($hashDest)\n" );
269
270 $status->error( 'filecopyerror', $srcPath, $dstPath );
271 $good = false;
272 }
273 }
274 }
275 if ( $good ) {
276 $this->chmod( $dstPath );
277 $status->successCount++;
278 } else {
279 $status->failCount++;
280 }
281 $status->success[$i] = $good;
282 }
283 return $status;
284 }
285
286 /**
287 * Deletes a batch of files. Each file can be a (zone, rel) pairs, a
288 * virtual url or a real path. It will try to delete each file, but
289 * ignores any errors that may occur
290 *
291 * @param $pairs array List of files to delete
292 * @return void
293 */
294 function cleanupBatch( $files ) {
295 foreach ( $files as $file ) {
296 if ( is_array( $file ) ) {
297 // This is a pair, extract it
298 list( $zone, $rel ) = $file;
299 $root = $this->getZonePath( $zone );
300 $path = "$root/$rel";
301 } else {
302 if ( self::isVirtualUrl( $file ) ) {
303 // This is a virtual url, resolve it
304 $path = $this->resolveVirtualUrl( $file );
305 } else {
306 // This is a full file name
307 $path = $file;
308 }
309 }
310
311 wfSuppressWarnings();
312 unlink( $path );
313 wfRestoreWarnings();
314 }
315 }
316
317 /**
318 * @return Status
319 */
320 function append( $srcPath, $toAppendPath, $flags = 0 ) {
321 $status = $this->newGood();
322
323 // Resolve the virtual URL
324 if ( self::isVirtualUrl( $toAppendPath ) ) {
325 $toAppendPath = $this->resolveVirtualUrl( $toAppendPath );
326 }
327 // Make sure the files are there
328 if ( !is_file( $toAppendPath ) )
329 $status->fatal( 'filenotfound', $toAppendPath );
330
331 if ( !is_file( $srcPath ) )
332 $status->fatal( 'filenotfound', $srcPath );
333
334 if ( !$status->isOk() ) return $status;
335
336 // Do the append
337 $chunk = file_get_contents( $srcPath );
338 if( $chunk === false ) {
339 $status->fatal( 'fileappenderrorread', $srcPath );
340 }
341
342 if( $status->isOk() ) {
343 if ( file_put_contents( $toAppendPath, $chunk, FILE_APPEND ) ) {
344 $status->value = $toAppendPath;
345 } else {
346 $status->fatal( 'fileappenderror', $srcPath, $toAppendPath);
347 }
348 }
349
350 if ( $flags & self::DELETE_SOURCE ) {
351 unlink( $srcPath );
352 }
353
354 return $status;
355 }
356
357 /* We can actually append to the files, so no-op needed here. */
358 function appendFinish( $toAppendPath ) {}
359
360 /**
361 * Checks existence of specified array of files.
362 *
363 * @param $files Array: URLs of files to check
364 * @param $flags Integer: bitwise combination of the following flags:
365 * self::FILES_ONLY Mark file as existing only if it is a file (not directory)
366 * @return Either array of files and existence flags, or false
367 */
368 function fileExistsBatch( $files, $flags = 0 ) {
369 if ( !file_exists( $this->directory ) || !is_readable( $this->directory ) ) {
370 return false;
371 }
372 $result = array();
373 foreach ( $files as $key => $file ) {
374 if ( self::isVirtualUrl( $file ) ) {
375 $file = $this->resolveVirtualUrl( $file );
376 }
377 if( $flags & self::FILES_ONLY ) {
378 $result[$key] = is_file( $file );
379 } else {
380 $result[$key] = file_exists( $file );
381 }
382 }
383
384 return $result;
385 }
386
387 /**
388 * Take all available measures to prevent web accessibility of new deleted
389 * directories, in case the user has not configured offline storage
390 * @return void
391 */
392 protected function initDeletedDir( $dir ) {
393 // Add a .htaccess file to the root of the deleted zone
394 $root = $this->getZonePath( 'deleted' );
395 if ( !file_exists( "$root/.htaccess" ) ) {
396 file_put_contents( "$root/.htaccess", "Deny from all\n" );
397 }
398 // Seed new directories with a blank index.html, to prevent crawling
399 file_put_contents( "$dir/index.html", '' );
400 }
401
402 /**
403 * Pick a random name in the temp zone and store a file to it.
404 * @param $originalName String: the base name of the file as specified
405 * by the user. The file extension will be maintained.
406 * @param $srcPath String: the current location of the file.
407 * @return FileRepoStatus object with the URL in the value.
408 */
409 function storeTemp( $originalName, $srcPath ) {
410 $date = gmdate( "YmdHis" );
411 $hashPath = $this->getHashPath( $originalName );
412 $dstRel = "$hashPath$date!$originalName";
413 $dstUrlRel = $hashPath . $date . '!' . rawurlencode( $originalName );
414
415 $result = $this->store( $srcPath, 'temp', $dstRel );
416 $result->value = $this->getVirtualUrl( 'temp' ) . '/' . $dstUrlRel;
417 return $result;
418 }
419
420 /**
421 * Remove a temporary file or mark it for garbage collection
422 * @param $virtualUrl String: the virtual URL returned by storeTemp
423 * @return Boolean: true on success, false on failure
424 */
425 function freeTemp( $virtualUrl ) {
426 $temp = "mwrepo://{$this->name}/temp";
427 if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) {
428 wfDebug( __METHOD__.": Invalid virtual URL\n" );
429 return false;
430 }
431 $path = $this->resolveVirtualUrl( $virtualUrl );
432 wfSuppressWarnings();
433 $success = unlink( $path );
434 wfRestoreWarnings();
435 return $success;
436 }
437
438 /**
439 * Publish a batch of files
440 * @param $triplets Array: (source,dest,archive) triplets as per publish()
441 * @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate
442 * that the source files should be deleted if possible
443 * @return Status
444 */
445 function publishBatch( $triplets, $flags = 0 ) {
446 // Perform initial checks
447 if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
448 return $this->newFatal( 'upload_directory_missing', $this->directory );
449 }
450 if ( !is_writable( $this->directory ) ) {
451 return $this->newFatal( 'upload_directory_read_only', $this->directory );
452 }
453 $status = $this->newGood( array() );
454 foreach ( $triplets as $i => $triplet ) {
455 list( $srcPath, $dstRel, $archiveRel ) = $triplet;
456
457 if ( substr( $srcPath, 0, 9 ) == 'mwrepo://' ) {
458 $triplets[$i][0] = $srcPath = $this->resolveVirtualUrl( $srcPath );
459 }
460 if ( !$this->validateFilename( $dstRel ) ) {
461 throw new MWException( 'Validation error in $dstRel' );
462 }
463 if ( !$this->validateFilename( $archiveRel ) ) {
464 throw new MWException( 'Validation error in $archiveRel' );
465 }
466 $dstPath = "{$this->directory}/$dstRel";
467 $archivePath = "{$this->directory}/$archiveRel";
468
469 $dstDir = dirname( $dstPath );
470 $archiveDir = dirname( $archivePath );
471 // Abort immediately on directory creation errors since they're likely to be repetitive
472 if ( !is_dir( $dstDir ) && !wfMkdirParents( $dstDir, null, __METHOD__ ) ) {
473 return $this->newFatal( 'directorycreateerror', $dstDir );
474 }
475 if ( !is_dir( $archiveDir ) && !wfMkdirParents( $archiveDir, null, __METHOD__ ) ) {
476 return $this->newFatal( 'directorycreateerror', $archiveDir );
477 }
478 if ( !is_file( $srcPath ) ) {
479 // Make a list of files that don't exist for return to the caller
480 $status->fatal( 'filenotfound', $srcPath );
481 }
482 }
483
484 if ( !$status->ok ) {
485 return $status;
486 }
487
488 foreach ( $triplets as $i => $triplet ) {
489 list( $srcPath, $dstRel, $archiveRel ) = $triplet;
490 $dstPath = "{$this->directory}/$dstRel";
491 $archivePath = "{$this->directory}/$archiveRel";
492
493 // Archive destination file if it exists
494 if( is_file( $dstPath ) ) {
495 // Check if the archive file exists
496 // This is a sanity check to avoid data loss. In UNIX, the rename primitive
497 // unlinks the destination file if it exists. DB-based synchronisation in
498 // publishBatch's caller should prevent races. In Windows there's no
499 // problem because the rename primitive fails if the destination exists.
500 if ( is_file( $archivePath ) ) {
501 $success = false;
502 } else {
503 wfSuppressWarnings();
504 $success = rename( $dstPath, $archivePath );
505 wfRestoreWarnings();
506 }
507
508 if( !$success ) {
509 $status->error( 'filerenameerror',$dstPath, $archivePath );
510 $status->failCount++;
511 continue;
512 } else {
513 wfDebug(__METHOD__.": moved file $dstPath to $archivePath\n");
514 }
515 $status->value[$i] = 'archived';
516 } else {
517 $status->value[$i] = 'new';
518 }
519
520 $good = true;
521 wfSuppressWarnings();
522 if ( $flags & self::DELETE_SOURCE ) {
523 if ( !rename( $srcPath, $dstPath ) ) {
524 $status->error( 'filerenameerror', $srcPath, $dstPath );
525 $good = false;
526 }
527 } else {
528 if ( !copy( $srcPath, $dstPath ) ) {
529 $status->error( 'filecopyerror', $srcPath, $dstPath );
530 $good = false;
531 }
532 }
533 wfRestoreWarnings();
534
535 if ( $good ) {
536 $status->successCount++;
537 wfDebug(__METHOD__.": wrote tempfile $srcPath to $dstPath\n");
538 // Thread-safe override for umask
539 $this->chmod( $dstPath );
540 } else {
541 $status->failCount++;
542 }
543 }
544 return $status;
545 }
546
547 /**
548 * Move a group of files to the deletion archive.
549 * If no valid deletion archive is configured, this may either delete the
550 * file or throw an exception, depending on the preference of the repository.
551 *
552 * @param $sourceDestPairs Array of source/destination pairs. Each element
553 * is a two-element array containing the source file path relative to the
554 * public root in the first element, and the archive file path relative
555 * to the deleted zone root in the second element.
556 * @return FileRepoStatus
557 */
558 function deleteBatch( $sourceDestPairs ) {
559 $status = $this->newGood();
560 if ( !$this->deletedDir ) {
561 throw new MWException( __METHOD__.': no valid deletion archive directory' );
562 }
563
564 /**
565 * Validate filenames and create archive directories
566 */
567 foreach ( $sourceDestPairs as $pair ) {
568 list( $srcRel, $archiveRel ) = $pair;
569 if ( !$this->validateFilename( $srcRel ) ) {
570 throw new MWException( __METHOD__.':Validation error in $srcRel' );
571 }
572 if ( !$this->validateFilename( $archiveRel ) ) {
573 throw new MWException( __METHOD__.':Validation error in $archiveRel' );
574 }
575 $archivePath = "{$this->deletedDir}/$archiveRel";
576 $archiveDir = dirname( $archivePath );
577 if ( !is_dir( $archiveDir ) ) {
578 if ( !wfMkdirParents( $archiveDir, null, __METHOD__ ) ) {
579 $status->fatal( 'directorycreateerror', $archiveDir );
580 continue;
581 }
582 $this->initDeletedDir( $archiveDir );
583 }
584 // Check if the archive directory is writable
585 // This doesn't appear to work on NTFS
586 if ( !is_writable( $archiveDir ) ) {
587 $status->fatal( 'filedelete-archive-read-only', $archiveDir );
588 }
589 }
590 if ( !$status->ok ) {
591 // Abort early
592 return $status;
593 }
594
595 /**
596 * Move the files
597 * We're now committed to returning an OK result, which will lead to
598 * the files being moved in the DB also.
599 */
600 foreach ( $sourceDestPairs as $pair ) {
601 list( $srcRel, $archiveRel ) = $pair;
602 $srcPath = "{$this->directory}/$srcRel";
603 $archivePath = "{$this->deletedDir}/$archiveRel";
604 if ( file_exists( $archivePath ) ) {
605 # A file with this content hash is already archived
606 wfSuppressWarnings();
607 $good = unlink( $srcPath );
608 wfRestoreWarnings();
609 if ( !$good ) {
610 $status->error( 'filedeleteerror', $srcPath );
611 }
612 } else{
613 wfSuppressWarnings();
614 $good = rename( $srcPath, $archivePath );
615 wfRestoreWarnings();
616 if ( !$good ) {
617 $status->error( 'filerenameerror', $srcPath, $archivePath );
618 } else {
619 $this->chmod( $archivePath );
620 }
621 }
622 if ( $good ) {
623 $status->successCount++;
624 } else {
625 $status->failCount++;
626 }
627 }
628 return $status;
629 }
630
631 /**
632 * Get a relative path for a deletion archive key,
633 * e.g. s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg
634 * @return string
635 */
636 function getDeletedHashPath( $key ) {
637 $path = '';
638 for ( $i = 0; $i < $this->deletedHashLevels; $i++ ) {
639 $path .= $key[$i] . '/';
640 }
641 return $path;
642 }
643
644 /**
645 * Call a callback function for every file in the repository.
646 * Uses the filesystem even in child classes.
647 * @return void
648 */
649 function enumFilesInFS( $callback ) {
650 $numDirs = 1 << ( $this->hashLevels * 4 );
651 for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
652 $hexString = sprintf( "%0{$this->hashLevels}x", $flatIndex );
653 $path = $this->directory;
654 for ( $hexPos = 0; $hexPos < $this->hashLevels; $hexPos++ ) {
655 $path .= '/' . substr( $hexString, 0, $hexPos + 1 );
656 }
657 if ( !file_exists( $path ) || !is_dir( $path ) ) {
658 continue;
659 }
660 $dir = opendir( $path );
661 if ($dir) {
662 while ( false !== ( $name = readdir( $dir ) ) ) {
663 call_user_func( $callback, $path . '/' . $name );
664 }
665 closedir( $dir );
666 }
667 }
668 }
669
670 /**
671 * Call a callback function for every file in the repository
672 * May use either the database or the filesystem
673 * @return void
674 */
675 function enumFiles( $callback ) {
676 $this->enumFilesInFS( $callback );
677 }
678
679 /**
680 * Get properties of a file with a given virtual URL
681 * The virtual URL must refer to this repo
682 * @return array
683 */
684 function getFileProps( $virtualUrl ) {
685 $path = $this->resolveVirtualUrl( $virtualUrl );
686 return File::getPropsFromPath( $path );
687 }
688
689 /**
690 * Path disclosure protection functions
691 *
692 * Get a callback function to use for cleaning error message parameters
693 */
694 function getErrorCleanupFunction() {
695 switch ( $this->pathDisclosureProtection ) {
696 case 'simple':
697 $callback = array( $this, 'simpleClean' );
698 break;
699 default:
700 $callback = parent::getErrorCleanupFunction();
701 }
702 return $callback;
703 }
704
705 function simpleClean( $param ) {
706 if ( !isset( $this->simpleCleanPairs ) ) {
707 global $IP;
708 $this->simpleCleanPairs = array(
709 $this->directory => 'public',
710 "{$this->directory}/temp" => 'temp',
711 $IP => '$IP',
712 dirname( __FILE__ ) => '$IP/extensions/WebStore',
713 );
714 if ( $this->deletedDir ) {
715 $this->simpleCleanPairs[$this->deletedDir] = 'deleted';
716 }
717 }
718 return strtr( $param, $this->simpleCleanPairs );
719 }
720
721 /**
722 * Chmod a file, supressing the warnings.
723 * @param $path String: the path to change
724 * @return void
725 */
726 protected function chmod( $path ) {
727 wfSuppressWarnings();
728 chmod( $path, $this->fileMode );
729 wfRestoreWarnings();
730 }
731
732 }