Skip to content

Commit

Permalink
Remove vendor dir, add support for PHP 8.0, drop support for PHP 7.1 …
Browse files Browse the repository at this point in the history
…and 7.2
  • Loading branch information
fisharebest committed Mar 11, 2021
1 parent 5e23e05 commit b0e778d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
7 changes: 3 additions & 4 deletions app/Http/RequestHandlers/ExportGedcomClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Capsule\Manager as DB;
use League\Flysystem\Filesystem;
use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider;
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -121,7 +122,8 @@ public function handle(ServerRequestInterface $request): ResponseInterface

// Create a new/empty .ZIP file
$temp_zip_file = stream_get_meta_data(tmpfile())['uri'];
$zip_adapter = new ZipArchiveAdapter($temp_zip_file);
$zip_provider = new FilesystemZipArchiveProvider($temp_zip_file, 0755);
$zip_adapter = new ZipArchiveAdapter($zip_provider);
$zip_filesystem = new Filesystem($zip_adapter);
$zip_filesystem->writeStream($download_filename, $tmp_stream);
fclose($tmp_stream);
Expand All @@ -146,9 +148,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
}
}

// Need to force-close ZipArchive filesystems.
$zip_adapter->getArchive()->close();

// Use a stream, so that we do not have to load the entire file into memory.
$stream_factory = app(StreamFactoryInterface::class);
assert($stream_factory instanceof StreamFactoryInterface);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/UploadMediaAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

$path = $folder . $filename;

if ($data_filesystem->has($path)) {
if ($data_filesystem->fileExists($path)) {
FlashMessages::addMessage(I18N::translate('The file %s already exists. Use another filename.', $path, 'error'));
continue;
}
Expand Down
7 changes: 3 additions & 4 deletions app/Module/ClippingsCartModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;
use League\Flysystem\Filesystem;
use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider;
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -279,7 +280,8 @@ public function postDownloadAction(ServerRequestInterface $request): ResponseInt

// Create a new/empty .ZIP file
$temp_zip_file = stream_get_meta_data(tmpfile())['uri'];
$zip_adapter = new ZipArchiveAdapter($temp_zip_file);
$zip_provider = new FilesystemZipArchiveProvider($temp_zip_file, 0755);
$zip_adapter = new ZipArchiveAdapter($zip_provider);
$zip_filesystem = new Filesystem($zip_adapter);

$media_filesystem = $tree->mediaFilesystem($data_filesystem);
Expand Down Expand Up @@ -375,9 +377,6 @@ public function postDownloadAction(ServerRequestInterface $request): ResponseInt
// Finally add the GEDCOM file to the .ZIP file.
$zip_filesystem->writeStream('clippings.ged', $stream);

// Need to force-close ZipArchive filesystems.
$zip_adapter->getArchive()->close();

// Use a stream, so that we do not have to load the entire file into memory.
$stream = app(StreamFactoryInterface::class)->createStreamFromFile($temp_zip_file);

Expand Down
17 changes: 8 additions & 9 deletions app/Services/HousekeepingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
use Fisharebest\Webtrees\Carbon;
use Illuminate\Database\Capsule\Manager as DB;
use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use League\Flysystem\UnableToDeleteDirectory;
use League\Flysystem\UnableToDeleteFile;

/**
* Clean up old data, files and folders.
Expand Down Expand Up @@ -461,17 +464,13 @@ private function deleteFileOrFolder(FilesystemOperator $filesystem, string $path
{
if ($filesystem->fileExists($path)) {
try {
$metadata = $filesystem->getMetadata($path);

if ($metadata['type'] === 'dir') {
$filesystem->delete($path);
} catch (FilesystemException | UnableToDeleteFile $ex) {
try {
$filesystem->deleteDirectory($path);
} catch (FilesystemException | UnableToDeleteDirectory $ex) {
return false;
}

if ($metadata['type'] === 'file') {
$filesystem->delete($path);
}
} catch (Exception $ex) {
return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Webtrees.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Webtrees
public const STABILITY = '-dev';

// Version number
public const VERSION = '2.0.13' . self::STABILITY;
public const VERSION = '2.1.0' . self::STABILITY;

// Project website.
public const URL = 'https://webtrees.net/';
Expand Down

0 comments on commit b0e778d

Please sign in to comment.