diff --git a/.wordpoints-dev-lib-config.sh b/.wordpoints-dev-lib-config.sh index 8f28047d..d250e9e2 100644 --- a/.wordpoints-dev-lib-config.sh +++ b/.wordpoints-dev-lib-config.sh @@ -7,7 +7,11 @@ export WORDPOINTS_PROJECT_TYPE=wordpoints function wordpoints-dev-lib-config() { # Use the develop branch for WPCS. - export WPCS_GIT_TREE=develop + if [[ $TRAVIS_BRANCH == stable || $TRAVIS_BRANCH =~ release ]]; then + export WPCS_GIT_TREE=0b8c692f1f44ce76721d1bb72bfbbe1d7bc1cc6a + else + export WPCS_GIT_TREE=develop + fi # Use PHPCS 2.7.0, since WPCS 0.11.0 requires it. export PHPCS_GIT_TREE=master diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c2dec6..0a9a7481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,16 @@ This is the developer changelog for WordPoints. For a user-centric changelog, se ## [Unreleased] -## [2.2.0] +## [2.2.1] - 2017-01-03 + +### Fixed + +- Infinite loop on the Points Types screen when an event had args that have relationships with other entities of the same type. #593 +- Points values not being formatted with prefix and suffix if one of these was not set. #588 +- "Table exists" errors from the uninstaller tests when running against WordPress 4.7+. #595 +- PHPCS errors being flagged when working on stable, by pinning the WPCS version. + +## [2.2.0] - 2016-12-08 ### Added @@ -277,6 +286,7 @@ This is the developer changelog for WordPoints. For a user-centric changelog, se - Notices for ophaned comments in comment points hooks. #436 [unreleased]: https://github.com/WordPoints/wordpoints/compare/stable...HEAD +[2.2.1]: https://github.com/WordPoints/wordpoints/compare/2.0.0...2.2.1 [2.2.0]: https://github.com/WordPoints/wordpoints/compare/2.1.5...2.2.0 [2.1.5]: https://github.com/WordPoints/wordpoints/compare/2.1.4...2.1.5 [2.1.4]: https://github.com/WordPoints/wordpoints/compare/2.1.3...2.1.4 diff --git a/package.json b/package.json index ecd80eb6..1ccacf20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wordpoints", - "version": "2.2.0", + "version": "2.2.1", "description": "Gamify your WordPress site with points.", "repository": { "type": "git", diff --git a/src/admin/assets/js/hooks/views.manifested.js b/src/admin/assets/js/hooks/views.manifested.js index f097282a..603f4a25 100644 --- a/src/admin/assets/js/hooks/views.manifested.js +++ b/src/admin/assets/js/hooks/views.manifested.js @@ -311,6 +311,19 @@ Args = Backbone.Model.extend({ return; } + // If this is an entity, check if that entity is already in the + // hierarchy, and don't add it again, to prevent infinite loops. + if ( hierarchy.length % 2 === 0 ) { + var loops = _.filter( hierarchy, function ( item ) { + return item.get( 'slug' ) === arg.get( 'slug' ); + }); + + // We allow it to loop twice, but not to add the entity a third time. + if ( loops.length > 1 ) { + return; + } + } + hierarchy.push( arg ); addMatching( subArgs, hierarchy ); diff --git a/src/components/points/includes/functions.php b/src/components/points/includes/functions.php index 8b522f8b..e47b5210 100644 --- a/src/components/points/includes/functions.php +++ b/src/components/points/includes/functions.php @@ -169,7 +169,7 @@ function wordpoints_format_points_filter( $formatted, $points, $type ) { $points_type = wordpoints_get_points_type( $type ); - if ( isset( $points_type['prefix'], $points_type['suffix'] ) ) { + if ( isset( $points_type['prefix'] ) ) { if ( $points < 0 ) { @@ -177,7 +177,11 @@ function wordpoints_format_points_filter( $formatted, $points, $type ) { $points_type['prefix'] = '-' . $points_type['prefix']; } - $formatted = esc_html( $points_type['prefix'] . $points . $points_type['suffix'] ); + $formatted = esc_html( $points_type['prefix'] . $points ); + } + + if ( isset( $points_type['suffix'] ) ) { + $formatted = $formatted . esc_html( $points_type['suffix'] ); } return $formatted; diff --git a/src/includes/constants.php b/src/includes/constants.php index 96dcd7bf..15b71963 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -22,7 +22,7 @@ * * @const WORDPOINTS_VERSION */ -define( 'WORDPOINTS_VERSION', '2.2.0' ); +define( 'WORDPOINTS_VERSION', '2.2.1' ); /** * The full path to the plugin's main directory. diff --git a/src/languages/wordpoints-es_ES.mo b/src/languages/wordpoints-es_ES.mo index afd47998..0ea2220e 100755 Binary files a/src/languages/wordpoints-es_ES.mo and b/src/languages/wordpoints-es_ES.mo differ diff --git a/src/languages/wordpoints-es_ES.po b/src/languages/wordpoints-es_ES.po index 5495d19f..c21368a0 100644 --- a/src/languages/wordpoints-es_ES.po +++ b/src/languages/wordpoints-es_ES.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WordPoints 1.5.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wordpoints\n" -"POT-Creation-Date: 2016-12-08 17:02:14+00:00\n" +"POT-Creation-Date: 2017-01-02 20:04:13+00:00\n" "PO-Revision-Date: 2015-02-24 19:20+0200\n" "Last-Translator: Gonzalo Exequiel Pedone \n" "Language-Team: Spanish \n" "Language-Team: Lithuanian \n" "Language-Team: Portuguese (Brazil) \n" "Language-Team: LANGUAGE \n" @@ -217,7 +217,7 @@ msgstr "" msgid "Activate %s" msgstr "" -#. #-#-#-#-# wordpoints.pot (WordPoints 2.2.0) #-#-#-#-# +#. #-#-#-#-# wordpoints.pot (WordPoints 2.2.1) #-#-#-#-# #. Plugin Name of the plugin/theme #: admin/includes/functions.php:69 #: components/points/admin/includes/functions.php:316 @@ -1695,11 +1695,11 @@ msgstr "" msgid "Auto Draft" msgstr "" -#: components/points/includes/functions.php:302 +#: components/points/includes/functions.php:306 msgid "This points type uses a custom meta key: %s" msgstr "" -#: components/points/includes/functions.php:327 +#: components/points/includes/functions.php:331 msgid "" "This points type uses a custom meta key (“%s”). If this key is " "also used by another plugin, changes made by it will not be logged. Only " diff --git a/src/readme.txt b/src/readme.txt index 0eef0a22..8f09b8f2 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TPXS6 Tags: points, awards, rewards, cubepoints, credits, gamify, multisite, ranks Requires at least: 4.6 Tested up to: 4.8-alpha-39357 -Stable tag: 2.2.0 +Stable tag: 2.2.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -114,6 +114,19 @@ screens. This plugin adheres to [Semantic Versioning](http://semver.org/). += 2.2.1 — 2017-01-03 = + +##### Fixed + +- The Points Types screen locking up when creating a new reaction for some events. +This only affected events where conditions could be created for items that could +relate to another item of the same type (like how a comment could have a parent +comment), causing an infinite loop. +- Points values not being formatted with the prefix if the suffix wasn't set, and +vice versa. This would only happen when the value wasn't set at all, not just when it +was empty, and so only applies to points types that were created programmatically. +Points types created through the UI were still formatted as expected. + = 2.2.0 — 2016-12-08 = **Requires: WordPress 4.6+** @@ -504,6 +517,10 @@ choosing the points type to add it to. * Initial release == Upgrade Notice == += 2.2.1 = +* Fixes a bug that could cause the Points Types screen to lock up in some +circumstances. + = 2.2.0 = * Introduces greater flexibility for Rate Limits for event reactions, and now differentiates points log entries that are hidden from some users. diff --git a/src/wordpoints.php b/src/wordpoints.php index a04fb525..118c4db6 100644 --- a/src/wordpoints.php +++ b/src/wordpoints.php @@ -4,7 +4,7 @@ * Plugin Name: WordPoints * Plugin URI: https://wordpoints.org/ * Description: Create one or more points systems for your site, and reward user activity. - * Version: 2.2.0 + * Version: 2.2.1 * Author: J.D. Grimes * Author URI: https://codesymphony.co/ * License: GPLv2 @@ -12,7 +12,7 @@ * Domain Path: /languages * * ---------------------------------------------------------------------------------| - * Copyright 2013-16 J.D. Grimes (email : jdg@codesymphony.co) + * Copyright 2013-17 J.D. Grimes (email : jdg@codesymphony.co) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 or later, as @@ -40,9 +40,9 @@ * * @package WordPoints * @author J.D. Grimes - * @version 2.2.0 + * @version 2.2.1 * @license https://opensource.org/licenses/gpl-license.php GPL, version 2 or later. - * @copyright 2013-16 J.D. Grimes + * @copyright 2013-17 J.D. Grimes */ /** diff --git a/tests/phpunit/tests/points/points.php b/tests/phpunit/tests/points/points.php index 582ff329..80b1d6f6 100644 --- a/tests/phpunit/tests/points/points.php +++ b/tests/phpunit/tests/points/points.php @@ -140,17 +140,61 @@ public function minimum_filter() { // /** - * Test that the result is unaltered by defualt. + * Test that the result is unaltered by default. * * @since 1.0.0 * * @covers ::wordpoints_format_points + * @covers ::wordpoints_format_points_filter */ public function test_default_format() { $this->assertEquals( '$5pts.', wordpoints_format_points( 5, 'points', 'testing' ) ); } + /** + * Test that it formats negative values correctly. + * + * @since 1.0.0 + * + * @covers ::wordpoints_format_points + * @covers ::wordpoints_format_points_filter + */ + public function test_format_negative() { + + $this->assertEquals( '-$5pts.', wordpoints_format_points( -5, 'points', 'testing' ) ); + } + + /** + * Test that it formats with the prefix even when the suffix isn't set. + * + * @since 1.0.0 + * + * @covers ::wordpoints_format_points + * @covers ::wordpoints_format_points_filter + */ + public function test_format_prefix() { + + wordpoints_add_points_type( array( 'name' => 'Credits', 'prefix' => '$' ) ); + + $this->assertEquals( '$5', wordpoints_format_points( 5, 'credits', 'testing' ) ); + } + + /** + * Test that it formats with the suffix even when the prefix isn't set. + * + * @since 1.0.0 + * + * @covers ::wordpoints_format_points + * @covers ::wordpoints_format_points_filter + */ + public function test_format_suffix() { + + wordpoints_add_points_type( array( 'name' => 'Credits', 'suffix' => 'c.' ) ); + + $this->assertEquals( '5c.', wordpoints_format_points( 5, 'credits', 'testing' ) ); + } + /** * Test that the 'wordpoints_points_display' filter is called. * @@ -163,8 +207,6 @@ public function test_format_filter() { add_filter( 'wordpoints_format_points', array( $this, 'format_filter' ), 10, 3 ); $this->assertEquals( '5points', wordpoints_format_points( 5, 'points', 'testing' ) ); - - remove_filter( 'wordpoints_format_points', array( $this, 'format_filter' ), 10, 3 ); } /** diff --git a/tests/phpunit/tests/un-installer-base.php b/tests/phpunit/tests/un-installer-base.php index 874558a6..2038c9c1 100644 --- a/tests/phpunit/tests/un-installer-base.php +++ b/tests/phpunit/tests/un-installer-base.php @@ -63,6 +63,18 @@ public function setUp() { delete_site_transient( 'wordpoints_all_site_ids' ); } + /** + * @since 2.2.1 + */ + public function tearDown() { + + global $wpdb; + + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}test" ); + + parent::tearDown(); + } + /** * Test that the slug and version are set on construction. * @@ -2952,6 +2964,10 @@ public function test_uninstall_points_hook() { */ public function test_uninstall_table() { + // We use real tables, because we can't check if a temporary table exists. + remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); + remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); + global $wpdb; $wpdb->query( "CREATE TABLE `{$wpdb->base_prefix}test` ( `id` BIGINT );" ); @@ -2972,6 +2988,10 @@ public function test_uninstall_table() { */ public function test_uninstall_table_site_context() { + // We use real tables, because we can't check if a temporary table exists. + remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); + remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); + global $wpdb; $wpdb->query( "CREATE TABLE `{$wpdb->prefix}test` ( `id` BIGINT );" ); @@ -2991,6 +3011,10 @@ public function test_uninstall_table_site_context() { */ public function test_uninstall__table() { + // We use real tables, because we can't check if a temporary table exists. + remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); + remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); + global $wpdb; $wpdb->query( "CREATE TABLE `{$wpdb->base_prefix}test` ( `id` BIGINT );" ); diff --git a/unbuilt/admin/assets/js/hooks/controllers/args.js b/unbuilt/admin/assets/js/hooks/controllers/args.js index d0d166a9..44030949 100644 --- a/unbuilt/admin/assets/js/hooks/controllers/args.js +++ b/unbuilt/admin/assets/js/hooks/controllers/args.js @@ -310,6 +310,19 @@ Args = Backbone.Model.extend({ return; } + // If this is an entity, check if that entity is already in the + // hierarchy, and don't add it again, to prevent infinite loops. + if ( hierarchy.length % 2 === 0 ) { + var loops = _.filter( hierarchy, function ( item ) { + return item.get( 'slug' ) === arg.get( 'slug' ); + }); + + // We allow it to loop twice, but not to add the entity a third time. + if ( loops.length > 1 ) { + return; + } + } + hierarchy.push( arg ); addMatching( subArgs, hierarchy );