Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testing] Test a pack of fclose #30510

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 129 additions & 9 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,56 +350,56 @@ matrix:

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: other
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: files
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: moveFilesFolders
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: renameFiles
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: renameFolders
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: trashbin
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: sharingInternalGroupsUsers
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: sharingExternalOther
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true
USE_FEDERATED_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: restrictSharing
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

Expand All @@ -408,3 +408,123 @@ matrix:
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BEHAT_SUITE: upload
DB_TYPE: mariadb
USE_SERVER: true
3 changes: 2 additions & 1 deletion lib/private/Preview/Bitmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) {
} catch (\Exception $e) {
Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), Util::ERROR);
return false;
} finally {
fclose($stream);
}

fclose($stream);

//new bitmap image object
$image = new \OC_Image();
Expand Down
4 changes: 3 additions & 1 deletion lib/private/Preview/SVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) {
$svg = new \Imagick();
$svg->setBackgroundColor(new \ImagickPixel('transparent'));

$content = stream_get_contents($file->fopen('r'));
$stream = $file->fopen('r');
$content = stream_get_contents($stream);
if (substr($content, 0, 5) !== '<?xml') {
$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
}
fclose($stream);

// Do not parse SVG files with references
if (stripos($content, 'xlink:href') !== false) {
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Preview/TXT.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function getMimeType() {
* {@inheritDoc}
*/
public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) {
$content = $file->fopen('r');
$content = stream_get_contents($content,3000);
$stream = $file->fopen('r');
$content = stream_get_contents($stream,3000);
fclose($stream);

//don't create previews of empty text files
if(trim($content) === '') {
Expand Down