/** * @expectedException RuntimeException * @expectedExceptionMessage Failed to open file: */ public function testConstruct_notReadable() { $filename = $this->makeTemp( __FUNCTION__ ); chmod( $filename, 0000 ); $stream = new UploadedFileStream( $filename ); }
When I run phpunit test as root
1) Wikimedia\ParamValidator\Util\UploadedFileStreamTest::testConstruct_notReadable Failed asserting that exception of type "RuntimeException" is thrown. /root/mediawiki-core/maintenance/doMaintenance.php:99
That means the script that run as root can read the file even the file mode is 0000. Example:
$filename = 'test.txt'; file_put_contents($filename, ''); chmod($filename, 0000); var_dump(is_readable($filename)); // bool (true) unlink($filename);