diff --git a/WpMailCatcher.php b/WpMailCatcher.php index 5ab5565..7c8608d 100644 --- a/WpMailCatcher.php +++ b/WpMailCatcher.php @@ -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 */ diff --git a/build/grunt/package.json b/build/grunt/package.json index 2b96d17..fe6d418 100644 --- a/build/grunt/package.json +++ b/build/grunt/package.json @@ -1,6 +1,6 @@ { "name": "WpMailCatcher", - "version": "2.1.4", + "version": "2.1.6", "lang_po_directory": "../../languages", "build_directory": "./..", "dist_directory": "../../assets", diff --git a/docker-compose.yml b/docker-compose.yml index 32ad436..bea94f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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 @@ -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: diff --git a/entrypoint.sh b/entrypoint.sh index e1b8a4d..318b753 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 diff --git a/languages/WpMailCatcher.pot b/languages/WpMailCatcher.pot index a7a4fcb..0f353cf 100644 --- a/languages/WpMailCatcher.pot +++ b/languages/WpMailCatcher.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: WpMailCatcher 2.1.4\n" "Report-Msgid-Bugs-To: wordpress@jamesward.io\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 \n" "Language-Team: LANGUAGE \n" @@ -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" diff --git a/phpcs.xml b/phpcs.xml index c72906a..a48dee1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,5 +2,6 @@ ./src */src/MailAdminTable.php$ + */testing/*$ \ No newline at end of file diff --git a/readme.txt b/readme.txt index a5ea8cc..544e55e 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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 diff --git a/src/Models/Logs.php b/src/Models/Logs.php index 95c10c4..c62ba6f 100644 --- a/src/Models/Logs.php +++ b/src/Models/Logs.php @@ -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 = [ @@ -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; @@ -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"; @@ -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); @@ -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']),