Skip to content

Commit d0e36ac

Browse files
Merge pull request #27 from stackkit/development
Fixed memory attachment bug and moved tests to Github Actions
2 parents f9bceb8 + d93cadb commit d0e36ac

16 files changed

+199
-115
lines changed

.github/workflows/run-tests.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
php-tests:
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
php: [7.4, 7.3, 7.2]
15+
laravel: [6.*, 5.8.*, 5.7.*, 5.6.*]
16+
os: [ubuntu-latest]
17+
include:
18+
- laravel: 6.*
19+
testbench: 4.*
20+
- laravel: 5.8.*
21+
testbench: 3.8.*
22+
- laravel: 5.7.*
23+
testbench: 3.7.*
24+
- laravel: 5.6.*
25+
testbench: 3.6.*
26+
exclude:
27+
- laravel: 5.7.*
28+
php: 7.4
29+
- laravel: 5.6.*
30+
php: 7.4
31+
- laravel: 5.5.*
32+
php: 7.4
33+
34+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
35+
36+
services:
37+
mysql:
38+
image: mysql:5.7.27
39+
env:
40+
MYSQL_USER: root
41+
MYSQL_ROOT_PASSWORD: root
42+
MYSQL_PASSWORD:
43+
MYSQL_ALLOW_EMPTY_PASSWORD: true
44+
MYSQL_DATABASE: test
45+
ports:
46+
- 3307:3306
47+
volumes:
48+
- $HOME/mysql:/var/lib/mysql
49+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v1
54+
55+
- name: Setup PHP
56+
uses: shivammathur/setup-php@v1
57+
with:
58+
php-version: ${{ matrix.php }}
59+
extensions: mbstring, dom, fileinfo, mysql
60+
coverage: none
61+
62+
- name: Install dependencies
63+
run: |
64+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
65+
composer update --prefer-stable --prefer-dist --no-interaction --no-suggest
66+
- name: Execute tests
67+
env:
68+
CI_DB_DRIVER: mysql
69+
CI_DB_HOST: 127.0.0.1
70+
CI_DB_PORT: 3307
71+
CI_DB_DATABASE: test
72+
CI_DB_USERNAME: root
73+
CI_DB_PASSWORD: root
74+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
vendor/
33
.DS_Store
44
composer.lock
5+
.phpunit.result.cache

.styleci.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 4.1.1 - 2020-01-11
8+
9+
**Fixed**
10+
11+
- Fixed inline attachments could not be stored
12+
- Fixed PHP 7.4 issue when reading empty Mailable from address
13+
714
## 4.1.0 - 2019-07-13
815

916
**Added**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="/logo.png">
33
</p>
44
<p align="center">
5-
<a href="https://travis-ci.org/stackkit/laravel-database-emails"><img src="https://travis-ci.org/stackkit/laravel-database-emails.svg?branch=master" alt="Build Status"></a>
5+
<img src="https://github.com/marickvantuil/laravel-database-emails/workflows/Run tests/badge.svg" alt="Build Status">
66
<a href="https://packagist.org/packages/stackkit/laravel-database-emails"><img src="https://poser.pugx.org/stackkit/laravel-database-emails/v/stable.svg" alt="Latest Stable Version"></a>
77
<a href="https://packagist.org/packages/stackkit/laravel-database-emails"><img src="https://poser.pugx.org/stackkit/laravel-database-emails/license.svg" alt="License"></a>
88
</p>

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
]
2626
}
2727
},
28+
"require": {
29+
"ext-json": "*"
30+
},
2831
"require-dev": {
29-
"illuminate/database": "5.5.*",
30-
"illuminate/console": "5.5.*",
31-
"illuminate/validation": "5.5.*",
32-
"orchestra/testbench": "^3.5",
33-
"orchestra/database": "^3.5",
34-
"phpunit/phpunit": "^6.0",
35-
"mockery/mockery": "^1.0",
36-
"dompdf/dompdf": "^0.8.2"
32+
"mockery/mockery": "^1.2",
33+
"orchestra/testbench": "^3.5 || ^3.6 || ^3.7 || ^3.8 || ^4.0",
34+
"symfony/console": "^4.4",
35+
"tecnickcom/tcpdf": "^6.3"
3736
}
3837
}

src/HasEncryptedAttributes.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ trait HasEncryptedAttributes
3232
'cc',
3333
'bcc',
3434
'variables',
35-
'attachments',
3635
];
3736

3837
/**
@@ -61,6 +60,25 @@ public function getAttribute($key)
6160
}
6261
}
6362

63+
// BC fix for attachments in 4.1.0 and lower.
64+
// Attachments were stored json encoded.
65+
// Because this doesn't work for raw attachments, value is now serialized.
66+
// Check if value is json encoded or serialized, and decode or unserialize accordingly.
67+
if ($key == 'attachments') {
68+
if (substr($value, 0, 2) === 'a:') {
69+
$unserialized = @unserialize($value);
70+
if ($value !== false) {
71+
$value = $unserialized;
72+
}
73+
} else {
74+
$decoded = json_decode($value, true);
75+
76+
if (! is_null($decoded)) {
77+
$value = $decoded;
78+
}
79+
}
80+
}
81+
6482
return $value;
6583
}
6684
}

src/MailableReader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ private function readFrom(EmailComposer $composer)
6868
{
6969
$from = reset($composer->getData('mailable')->from);
7070

71+
if (!$from) {
72+
return;
73+
}
74+
7175
$composer->from(
7276
$from['address'],
7377
$from['name']

src/Preparer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private function prepareAttachments(EmailComposer $composer)
198198
}
199199

200200
$composer->getEmail()->fill([
201-
'attachments' => json_encode($attachments),
201+
'attachments' => serialize($attachments),
202202
]);
203203
}
204204

0 commit comments

Comments
 (0)