* @return null|UploadBase
*/
public static function createFromRequest( &$request, $type = null ) {
- $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
+ $type = $type ?: $request->getVal( 'wpSourceType', 'File' );
if ( !$type ) {
return null;
/**
* @param string $tempPath File system path to temporary file containing the upload
- * @param int $fileSize
+ * @param int|null $fileSize
*/
protected function setTempFile( $tempPath, $fileSize = null ) {
$this->mTempPath = $tempPath;
if ( !is_array( $error ) ) {
$error = [ $error ];
}
- return call_user_func_array( 'Status::newFatal', $error );
+ return Status::newFatal( ...$error );
}
$status = $this->getLocalFile()->upload(
if ( !$isPartial ) {
$error = $this->runUploadStashFileHook( $user );
if ( $error ) {
- return call_user_func_array( 'Status::newFatal', $error );
+ return Status::newFatal( ...$error );
}
}
try {
* file again.
*
* @deprecated since 1.28 Use tryStashFile() instead
- * @param User $user
+ * @param User|null $user
* @return UploadStashFile Stashed file
* @throws UploadStashBadPathException
* @throws UploadStashFileException
/**
* Implementation for stashFile() and tryStashFile().
*
- * @param User $user
+ * @param User|null $user
* @return UploadStashFile Stashed file
*/
protected function doStashFile( User $user = null ) {
*/
public static function checkXMLEncodingMissmatch( $file ) {
global $wgSVGMetadataCutoff;
- $contents = file_get_contents( $file, false, null, -1, $wgSVGMetadataCutoff );
+ $contents = file_get_contents( $file, false, null, 0, $wgSVGMetadataCutoff );
$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
* @todo Replace this with a whitelist filter!
* @param string $element
* @param array $attribs
- * @param array $data
+ * @param array|null $data
* @return bool
*/
public function checkSvgScriptCallback( $element, $attribs, $data = null ) {
# look up scanner configuration
$command = $wgAntivirusSetup[$wgAntivirus]['command'];
$exitCodeMap = $wgAntivirusSetup[$wgAntivirus]['codemap'];
- $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ) ?
- $wgAntivirusSetup[$wgAntivirus]['messagepattern'] : null;
+ $msgPattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ?? null;
if ( strpos( $command, "%f" ) === false ) {
# simple pattern: append file to scan