Skip to content

Commit

Permalink
Merge branch 'release/B24.cardinal'
Browse files Browse the repository at this point in the history
  • Loading branch information
Camwyn committed Mar 20, 2024
2 parents 21a4936 + c43a178 commit 4f84ad0
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/link-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
template-project-url: https://github.com/orgs/the-events-calendar/projects/29
project-owner: 'tec-bot'
base-branch-pattern: 'release/*'
name-prefix-remove: 'release/'
name-prefix-remove: 'release/'
285 changes: 132 additions & 153 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tribe-common",
"version": "5.2.3",
"version": "5.2.4",
"repository": "git@github.com:the-events-calendar/tribe-common.git",
"_resourcepath": "src/resources",
"_domainPath": "lang",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
</rule>

<exclude-pattern>*/tests/_support/_generated/*</exclude-pattern>
<exclude-pattern>*/tests/_data/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>
6 changes: 6 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
== Changelog ==

= [5.2.4] 2024-03-20 =

* Fix - Resolves a PHP 8.2 deprecation error on `Date_Utils` - `PHP Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /.../wp-content/plugins/the-events-calendar/common/src/Tribe/Date_Utils.php on line 256`. [ECP-1620]
* Fix - This fixes an issue where a template with a duplicate name but located in different folders is called it would always reference the first file. Updated the key to be unique by folder as well. [ECP-1627]
* Language - 0 new strings added, 0 updated, 1 fuzzied, and 0 obsoleted

= [5.2.3] 2024-02-19 =

* Tweak - Refactor JS logic to prevent ticketing of recurring events. [ET-1936]
Expand Down
10 changes: 5 additions & 5 deletions src/Tribe/Date_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ public static function datetime_from_format( $format, $date ) {
/**
* Returns the date only.
*
* @param int|string $date The date (timestamp or string).
* @param bool $isTimestamp Is $date in timestamp format?
* @param string|null $format The format used
* @param int|string $date The date (timestamp or string). If an empty or null date is provided it will default to 'now'.
* @param bool $is_timestamp Whether or not $date is in timestamp format.
* @param string|null $format The format used.
*
* @return string The date only in DB format.
*/
public static function date_only( $date, $isTimestamp = false, $format = null ) {
$date = $isTimestamp ? $date : strtotime( $date );
public static function date_only( $date, $is_timestamp = false, $format = null ) {
$date = $is_timestamp ? $date : strtotime( $date ?? 'now' );

if ( is_null( $format ) ) {
$format = self::DBDATEFORMAT;
Expand Down
2 changes: 1 addition & 1 deletion src/Tribe/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Tribe__Main {
const OPTIONNAME = 'tribe_events_calendar_options';
const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options';
const FEED_URL = 'https://theeventscalendar.com/feed/';
const VERSION = '5.2.3';
const VERSION = '5.2.4';

protected $plugin_context;
protected $plugin_context_class;
Expand Down
5 changes: 3 additions & 2 deletions src/Tribe/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,9 @@ public function template( $name, $context = [], $echo = true ) {
return false;
}

// Key we'll use for in-memory caching of expensive operations.
$cache_name_key = is_array( $name ) ? implode( '/', $name ) : $name;
// Key we'll use for memoizing of expensive operations.
$folder_path = implode( '/', $this->folder );
$cache_name_key = $folder_path . ( is_array( $name ) ? implode( '/', $name ) : $name );

// Cache template name massaging so we don't have to repeat these actions.
if ( ! isset( $template_names[ $cache_name_key ] ) ) {
Expand Down
3 changes: 3 additions & 0 deletions tests/_data/plugin-views/templates/etc/dummy-template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="test">
Our duplicate.
</div>
37 changes: 37 additions & 0 deletions tests/wpunit/Tribe/Date_UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,41 @@ public function test_shifted_end_start_of_day( $input, $expected, $cutoff ){

$this->assertEquals( $expected, $end_of_day->format( Date_Utils::DBDATETIMEFORMAT ) );
}

public function date_only_data_provider() {
return [
'null' => [
date( 'Y-m-d' ),
null,
],
'2023-01-03 3:22am' => [
'2023-01-03',
'2023-01-03 3:22am',
],
'2022-12-03' => [
'2022-12-03',
'2022-12-03',
],
'december 12th 2010' => [
'2010-12-12',
'december 12th 2010',
],
'1702341373' => [
'2023-12-12',
1702341373,
true,
],
];
}

/**
* Validates date_only() works as expected.
*
* @dataProvider date_only_data_provider
* @test
*/
public function test_date_only( $expected, $date, $is_timestamp = false ) {
$date_only = Date_Utils::date_only( $date, $is_timestamp );
$this->assertEquals( $expected, $date_only );
}
}
1 change: 1 addition & 0 deletions tests/wpunit/Tribe/Support/Template_CheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function test_detects_shipped_views() {
'templates/dummy-valid-template-01.php' => '',
'templates/dummy-valid-template-03.php' => '',
'templates/dummy-valid-template-02.php' => '',
'templates/etc/dummy-template.php' => '',
'modules/alpha.php' => '1.4',
'modules/beta.php' => '',
'modules/gamma.php' => '',
Expand Down
21 changes: 21 additions & 0 deletions tests/wpunit/Tribe/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
include_once codecept_data_dir( 'classes/Dummy_Plugin_Origin.php' );

class TemplateTest extends \Codeception\TestCase\WPTestCase {
/**
* @test
*/
public function should_not_memoize_same_name_template() {
$plugin = new Dummy_Plugin_Origin();

// Template should be unique by folder path + name.
$template = new Template();
$template->set_template_origin( $plugin )->set_template_folder( 'tests/_data/plugin-views/templates' );
$template2 = new Template();
$template2->set_template_origin( $plugin )->set_template_folder( 'tests/_data/plugin-views/templates/etc' );

// Same name, but different folders.
$html1 = $template->template( 'dummy-template', [], false );
$html2 = $template2->template( 'dummy-template', [], false );

// Should find two different templates.
$this->assertNotEquals( $html1, $html2 );
$this->assertContains( 'Our duplicate.', $html2 );
$this->assertContains( 'Our own test.', $html1 );
}

/**
* It should allow setting a number of values at the same time
Expand Down
2 changes: 1 addition & 1 deletion tribe-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Tribe Common
* Description: An event settings framework for managing shared options
* Version: 5.2.3
* Version: 5.2.4
* Author: The Events Calendar
* Author URI: http://evnt.is/1x
* Text Domain: tribe-common
Expand Down

0 comments on commit 4f84ad0

Please sign in to comment.