Skip to content

Commit 75b9519

Browse files
committed
Releasing 1.0.3
2 parents 979536e + 3ba1e7b commit 75b9519

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

composer.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@
1919
"technicalguru/utils" : "~1",
2020
"phpmailer/phpmailer" : "^6.1",
2121
"symfony/polyfill-mbstring" : "^1.20",
22-
"technicalguru/database" : "~1",
22+
"technicalguru/database" : "^1.1",
2323
"phpunit/phpunit": "^9.4"
2424
},
2525
"autoload" : {
2626
"psr-4" : {
27-
"TgEmail\\" : "src/TgEmail/",
28-
"" : ""
27+
"TgEmail\\" : "src/TgEmail/"
2928
},
3029
"psr-0" : {
3130
"TgEmail" : "src/TgEmail"
3231
}
3332
},
33+
"extra": {
34+
"branch-alias": {
35+
"dev-master": "1.0-dev"
36+
}
37+
},
3438
"require-dev" : {
3539
}
3640
}

src/TgEmail/EmailsDAO.php

+30-30
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ class EmailsDAO extends DAO {
1313

1414
/**
1515
*/
16-
public function __construct($database, $tableName = '#__mail_queue', $modelClass = 'TgEmail\\Email', $idColumn = 'uid') {
17-
parent::__construct($database, $tableName, $modelClass, $idColumn);
18-
$this->checkTable();
16+
public function __construct($database, $tableName = '#__mail_queue', $modelClass = 'TgEmail\\Email', $idColumn = 'uid', $checkTable = FALSE) {
17+
parent::__construct($database, $tableName, $modelClass, $idColumn, $checkTable);
1918
}
20-
21-
public function checkTable() {
22-
$res = $this->database->query('SELECT * FROM '.$this->tableName);
23-
if ($res === FALSE) {
24-
// Create it (try)
25-
$sql =
26-
'CREATE TABLE `'.$this->tableName.'` ( '.
27-
'`'.$this->idColumn.'` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT \'ID of queue element\', '.
28-
'`sender` VARCHAR(200) NOT NULL COMMENT \'sender address\', '.
29-
'`reply_to` VARCHAR(200) NULL COMMENT \'Reply-To address\', '.
30-
'`recipients` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'email recipients\', '.
31-
'`subject` VARCHAR(200) NOT NULL COMMENT \'email subject\', '.
32-
'`body` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'email bodies\', '.
33-
'`attachments` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'attachment data\', '.
34-
'`queued_time` DATETIME NOT NULL COMMENT \'Time the email was queued\', '.
35-
'`status` VARCHAR(20) NOT NULL COMMENT \'email subject\', '.
36-
'`sent_time` DATETIME NULL COMMENT \'Time the email was sent successfully\', '.
37-
'`failed_attempts` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT \'Number of failed sending attempts\', '.
38-
'PRIMARY KEY (`'.$this->idColumn.'`) '.
39-
') ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT = \'Email Queue\'';
40-
41-
$res = $this->database->query($sql);
42-
if ($res === FALSE) {
43-
throw new EmailException('Cannot create table '.$this->tableName.': '.$this->database->error());
44-
}
45-
}
46-
19+
20+
/**
21+
* Implements the method from base class.
22+
* @return boolean TRUE when table could be created. An exception is thrown when the method fails.
23+
*/
24+
public function createTable() {
25+
// Create it (try)
26+
$sql =
27+
'CREATE TABLE `'.$this->tableName.'` ( '.
28+
'`'.$this->idColumn.'` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT \'ID of queue element\', '.
29+
'`sender` VARCHAR(200) NOT NULL COMMENT \'sender address\', '.
30+
'`reply_to` VARCHAR(200) NULL COMMENT \'Reply-To address\', '.
31+
'`recipients` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'email recipients\', '.
32+
'`subject` VARCHAR(200) NOT NULL COMMENT \'email subject\', '.
33+
'`body` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'email bodies\', '.
34+
'`attachments` TEXT COLLATE utf8mb4_bin NOT NULL COMMENT \'attachment data\', '.
35+
'`queued_time` DATETIME NOT NULL COMMENT \'Time the email was queued\', '.
36+
'`status` VARCHAR(20) NOT NULL COMMENT \'email subject\', '.
37+
'`sent_time` DATETIME NULL COMMENT \'Time the email was sent successfully\', '.
38+
'`failed_attempts` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT \'Number of failed sending attempts\', '.
39+
'PRIMARY KEY (`'.$this->idColumn.'`) '.
40+
') ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT = \'Email Queue\'';
41+
42+
$res = $this->database->query($sql);
43+
if ($res === FALSE) {
44+
throw new EmailException('Cannot create table '.$this->tableName.': '.$this->database->error());
45+
}
46+
return TRUE;
4747
}
4848

4949
public function housekeeping($maxSentDays = 90, $maxFailedDays = 180) {

test.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
2-
vendor/phpunit/phpunit/phpunit tests/
1+
# Test script
2+
composer update
3+
RC=./vendor/phpunit/phpunit/phpunit tests
4+
rm -rf vendor composer.lock
5+
exit $RC
36

0 commit comments

Comments
 (0)