Skip to content

Commit

Permalink
Merge pull request #192 from JWardee/v2.1.6
Browse files Browse the repository at this point in the history
V2.1.6
  • Loading branch information
JWardee authored Nov 25, 2023
2 parents 1d31f8c + 551c27e commit 2b8d3dc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion WpMailCatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Domain Path: /languages
Description: Logging your mail will stop you from ever losing your emails again! This fast, lightweight plugin (under 140kb in size!) is also useful for debugging or backing up your messages.
Author: James Ward
Version: 2.1.5
Version: 2.1.6
Author URI: https://jamesward.io
Donate link: https://paypal.me/jamesmward
*/
Expand Down
2 changes: 1 addition & 1 deletion build/grunt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WpMailCatcher",
"version": "2.1.4",
"version": "2.1.6",
"lang_po_directory": "../../languages",
"build_directory": "./..",
"dist_directory": "../../assets",
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ services:
WORDPRESS_DB_USER: ${DB_USERNAME}
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
WORDPRESS_DB_NAME: ${DB_DATABASE}
restart: always
mysql:
container_name: mysql
image: mysql:5.7
Expand All @@ -40,7 +39,6 @@ services:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- wp_mysql_data:/var/lib/mysql
restart: always
mysql_testing:
container_name: mysql_testing
image: mysql:5.7
Expand All @@ -53,7 +51,6 @@ services:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- wp_mysql_data_testing:/var/lib/mysql
restart: always
composer:
container_name: composer
build:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export DB_DATABASE=wordpress
export DB_USERNAME=wp_mail_catcher
export DB_PASSWORD=password
export PHP_VERSION=8.0
export WP_VERSION=latest
export WP_VERSION=6.4.1

CMD=$1

Expand Down
4 changes: 2 additions & 2 deletions languages/WpMailCatcher.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WpMailCatcher 2.1.4\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2023-10-28 12:40+0000\n"
"POT-Creation-Date: 2023-11-09 20:31+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -30,7 +30,7 @@ msgstr ""
msgid "Once a month"
msgstr ""

#: ../../src/GeneralHelper.php:221
#: ../../src/GeneralHelper.php:222
#, php-format
msgctxt "%s = human-readable time difference"
msgid "%s"
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<file>./src</file>
<exclude-pattern>*/src/MailAdminTable.php$</exclude-pattern>
<exclude-pattern>*/testing/*$</exclude-pattern>
<rule ref="PSR12" />
</ruleset>
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: mail logging, email log, email logger, logging, email logging, mail, crm
Requires at least: 4.7
Tested up to: 6.4
Requires PHP: 7.4
Stable tag: 2.1.5
Stable tag: 2.1.6
License: GNU General Public License v3.0
License URI: https://raw.githubusercontent.com/JWardee/wp-mail-catcher/master/LICENSE
Donate link: https://paypal.me/jamesmward
Expand Down Expand Up @@ -94,6 +94,10 @@ Great! Please leave a note in our (GitHub tracker)

== Changelog ==

= 2.1.6 =

- Fix: Logs not appearing in WP versions under 6.2

= 2.1.5 =

- Fix: Html emails are now decoded before being rendered
Expand Down
24 changes: 15 additions & 9 deletions src/Models/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static function get(array $args = [])
'column_blacklist' => []
];

$validOrderByColumns = ['time', 'email_to', 'subject'];

if (isset($args['orderby']) && !in_array($args['orderby'], $validOrderByColumns)) {
unset($args['orderby']);
}

$args = array_merge($defaults, $args);

$defaultColumns = [
Expand All @@ -84,9 +90,9 @@ public static function get(array $args = [])
}

$columnsToSelect = array_diff($defaultColumns, $args['column_blacklist']);
$placeholderValues = $columnsToSelect;
$columnToSelectPlaceholders = array_fill(0, count($columnsToSelect), '%i');
$sql = "SELECT " . implode(',', $columnToSelectPlaceholders) . "
$placeholderValues = [];

$sql = "SELECT " . implode(',', $columnsToSelect) . "
FROM " . $wpdb->prefix . GeneralHelper::$tableName . " ";

$whereClause = false;
Expand Down Expand Up @@ -140,10 +146,7 @@ public static function get(array $args = [])
}

$order = strtolower($args['order']) === "desc" ? "DESC" : "ASC";
$sql .= "ORDER BY %i " . $order . " ";
$placeholderValues = array_merge($placeholderValues, [
$args['orderby']
]);
$sql .= "ORDER BY " . $args['orderby'] . " " . $order . " ";

if ($args['posts_per_page'] != -1) {
$sql .= "LIMIT %d OFFSET %d";
Expand All @@ -154,7 +157,10 @@ public static function get(array $args = [])
]);
}

$sql = $wpdb->prepare($sql, $placeholderValues);
if (count($placeholderValues)) {
$sql = $wpdb->prepare($sql, $placeholderValues);
}

$results = $wpdb->get_results($sql, ARRAY_A);
$results = self::dbResultTransform($results, $args);

Expand Down Expand Up @@ -194,7 +200,7 @@ private static function dbResultTransform($results, $args = [])
// This will exist if the db_version is >= 2.0.0
if (isset($result['is_html']) && $result['is_html']) {
$result['is_html'] = (bool)$result['is_html'];
// Otherwise resort to the original method
// Otherwise resort to the original method
} elseif (isset($result['additional_headers'])) {
$result['is_html'] = GeneralHelper::doesArrayContainSubString(
str_replace(' ', '', $result['additional_headers']),
Expand Down

0 comments on commit 2b8d3dc

Please sign in to comment.