}
if ( !empty( $params['async'] ) ) { // deferred
- $tempFile = TempFSFile::factory( 'create_', 'tmp', $this->tmpDirectory );
+ $tempFile = $this->tmpFileFactory->newTempFSFile( 'create_', 'tmp' );
if ( !$tempFile ) {
$status->fatal( 'backend-fail-create', $params['dst'] );
} else {
// Create a new temporary file with the same extension...
$ext = FileBackend::extensionFromPath( $src );
- $tmpFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory );
+ $tmpFile = $this->tmpFileFactory->newTempFSFile( 'localcopy_', $ext );
if ( !$tmpFile ) {
$tmpFiles[$src] = null;
} else {
* Listen for E_WARNING errors and track whether any happen
*/
protected function trapWarnings() {
- $this->hadWarningErrors[] = false; // push to stack
- set_error_handler( [ $this, 'handleWarning' ], E_WARNING );
+ // push to stack
+ $this->hadWarningErrors[] = false;
+ set_error_handler( function ( $errno, $errstr ) {
+ // more detailed error logging
+ $this->logger->error( $errstr );
+ $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true;
+
+ // suppress from PHP handler
+ return true;
+ }, E_WARNING );
}
/**
* @return bool
*/
protected function untrapWarnings() {
- restore_error_handler(); // restore previous handler
- return array_pop( $this->hadWarningErrors ); // pop from stack
- }
-
- /**
- * @param int $errno
- * @param string $errstr
- * @return bool
- * @private
- */
- public function handleWarning( $errno, $errstr ) {
- $this->logger->error( $errstr ); // more detailed error logging
- $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true;
-
- return true; // suppress from PHP handler
+ // restore previous handler
+ restore_error_handler();
+ // pop from stack
+ return array_pop( $this->hadWarningErrors );
}
}