Skip to content

Commit a49cfd0

Browse files
Merge branch 'master' into feature-docker-refinements
2 parents 03191b3 + 07d9035 commit a49cfd0

28 files changed

Lines changed: 887 additions & 41 deletions

.github/stale.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
# Number of days of inactivity before an Issue or Pull Request becomes stale
4+
daysUntilStale: 550
5+
6+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8+
daysUntilClose: 7
9+
10+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11+
onlyLabels: []
12+
13+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14+
exemptLabels:
15+
- "confirmed bug"
16+
- security
17+
- "long-range planning"
18+
19+
# Set to true to ignore issues in a project (defaults to false)
20+
exemptProjects: false
21+
22+
# Set to true to ignore issues in a milestone (defaults to false)
23+
exemptMilestones: true
24+
25+
# Set to true to ignore issues with an assignee (defaults to false)
26+
exemptAssignees: false
27+
28+
# Label to use when marking as stale
29+
staleLabel: wontfix
30+
31+
# Comment to post when marking as stale. Set to `false` to disable
32+
markComment: >
33+
This issue has been automatically marked as stale because it has not had
34+
recent activity. It will be closed if no further activity occurs. Thank you
35+
for your contributions.
36+
37+
# Comment to post when removing the stale label.
38+
# unmarkComment: >
39+
# Your comment here.
40+
41+
# Comment to post when closing a stale Issue or Pull Request.
42+
# closeComment: >
43+
# Your comment here.
44+
45+
# Limit the number of actions per hour, from 1-30. Default is 30
46+
limitPerRun: 30
47+
48+
# Limit to only `issues` or `pulls`
49+
# only: issues
50+
51+
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
52+
# pulls:
53+
# daysUntilStale: 30
54+
# markComment: >
55+
# This pull request has been automatically marked as stale because it has not had
56+
# recent activity. It will be closed if no further activity occurs. Thank you
57+
# for your contributions.
58+
59+
# issues:
60+
# exemptLabels:
61+
# - confirmed

CHANGELOG.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## [v4.2.1]
9-
- Fix Italian translation ([#950])
10-
- User Registration fails when trying to register two accounts with the same email address ([#953])
9+
10+
### Added
11+
- `UserFrosting\Sprinkle\Core\Database\Models\Session` model for the `sessions` db table.
12+
- `TEST_SESSION_HANDLER` environment variable to set the session save handler to use for Testing.
13+
- `withDatabaseSessionHandler` Trait for testing. Use `$this->useDatabaseSessionHandler()` to use database session handler in tests.
14+
15+
### Fixed
16+
- Italian translation ([#950])
17+
- User Registration failing when trying to register two accounts with the same email address ([#953])
18+
- Bad test case for `CoreController::getAsset`.
19+
- User Model `forceDelete` doesn't remove the record from the DB ([#951])
20+
- Fix PHP Fatal error that can be thrown when registering a new User
21+
- Session not working with database handler ([#952])
22+
- Remove any persistences when forceDeleting user to prevent Foreign Key Constraints issue ([#963])
23+
- More helpful error message in checkEnvironment.php (Thanks @amosfolz; [#958])
24+
- Hide locale select from UI if only one locale is available (Thanks @avsdev-cw; [#968])
25+
- Download CSV filename error ([#893])
1126

1227
## [v4.2.0]
1328
### Changed Requirements
@@ -706,10 +721,16 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
706721
[#869]: https://github.com/userfrosting/UserFrosting/issues/869
707722
[#872]: https://github.com/userfrosting/UserFrosting/issues/872
708723
[#888]: https://github.com/userfrosting/UserFrosting/issues/888
724+
[#893]: https://github.com/userfrosting/UserFrosting/issues/893
709725
[#919]: https://github.com/userfrosting/UserFrosting/issues/919
710726
[#940]: https://github.com/userfrosting/UserFrosting/issues/940
711727
[#950]: https://github.com/userfrosting/UserFrosting/issues/950
728+
[#951]: https://github.com/userfrosting/UserFrosting/issues/951
729+
[#952]: https://github.com/userfrosting/UserFrosting/issues/952
712730
[#953]: https://github.com/userfrosting/UserFrosting/issues/953
731+
[#958]: https://github.com/userfrosting/UserFrosting/issues/958
732+
[#963]: https://github.com/userfrosting/UserFrosting/issues/963
733+
[#968]: https://github.com/userfrosting/UserFrosting/issues/968
713734

714735
[v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0
715736
[v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v4.2.1

app/defines.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace UserFrosting;
1111

1212
// Some standard defines
13-
define('UserFrosting\VERSION', '4.2.0');
13+
define('UserFrosting\VERSION', '4.2.1');
1414
define('UserFrosting\DS', '/');
1515
define('UserFrosting\PHP_MIN_VERSION', '5.6');
1616
define('UserFrosting\PHP_RECOMMENDED_VERSION', '7.1');

app/sprinkles/account/src/Controller/AccountController.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,22 @@ public function pageRegister(Request $request, Response $response, $args)
509509
// Get locale information
510510
$currentLocales = $localePathBuilder->getLocales();
511511

512+
// Hide the locale field if there is only 1 locale available
513+
$fields = [
514+
'hidden' => [],
515+
'disabled' => []
516+
];
517+
if (count($config->getDefined('site.locales.available')) <= 1) {
518+
$fields['hidden'][] = 'locale';
519+
}
520+
512521
return $this->ci->view->render($response, 'pages/register.html.twig', [
513522
'page' => [
514523
'validators' => [
515524
'register' => $validatorRegister->rules('json', false)
516525
]
517526
],
527+
'fields' => $fields,
518528
'locales' => [
519529
'available' => $config['site.locales.available'],
520530
'current' => end($currentLocales)
@@ -658,8 +668,18 @@ public function pageSettings(Request $request, Response $response, $args)
658668
// Get a list of all locales
659669
$locales = $config->getDefined('site.locales.available');
660670

671+
// Hide the locale field if there is only 1 locale available
672+
$fields = [
673+
'hidden' => [],
674+
'disabled' => []
675+
];
676+
if (count($config->getDefined('site.locales.available')) <= 1) {
677+
$fields['hidden'][] = 'locale';
678+
}
679+
661680
return $this->ci->view->render($response, 'pages/account-settings.html.twig', [
662681
'locales' => $locales,
682+
'fields' => $fields,
663683
'page' => [
664684
'validators' => [
665685
'account_settings' => $validatorAccountSettings->rules('json', false),
@@ -766,6 +786,11 @@ public function profile(Request $request, Response $response, $args)
766786

767787
$error = false;
768788

789+
// Ensure that in the case of using a single locale, that the locale is set
790+
if (count($config->getDefined('site.locales.available')) <= 1) {
791+
$data['locale'] = $currentUser->locale;
792+
}
793+
769794
// Validate, and halt on validation errors.
770795
$validator = new ServerSideValidator($schema, $this->ci->translator);
771796
if (!$validator->validate($data)) {
@@ -877,6 +902,11 @@ public function register(Request $request, Response $response, $args)
877902

878903
$error = false;
879904

905+
// Ensure that in the case of using a single locale, that the locale is set
906+
if (count($config->getDefined('site.locales.available')) <= 1) {
907+
$data['locale'] = $config['site.registration.user_defaults.locale'];
908+
}
909+
880910
// Validate request data
881911
$validator = new ServerSideValidator($schema, $this->ci->translator);
882912
if (!$validator->validate($data)) {
@@ -1160,6 +1190,11 @@ public function settings(Request $request, Response $response, $args)
11601190

11611191
$error = false;
11621192

1193+
// Ensure that in the case of using a single locale, that the locale is set
1194+
if (count($config->getDefined('site.locales.available')) <= 1) {
1195+
$data['locale'] = $currentUser->locale;
1196+
}
1197+
11631198
// Validate, and halt on validation errors.
11641199
$validator = new ServerSideValidator($schema, $this->ci->translator);
11651200
if (!$validator->validate($data)) {

app/sprinkles/account/src/Database/Models/User.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,18 @@ public function delete($hardDelete = false)
188188
// Remove all role associations
189189
$this->roles()->detach();
190190

191-
// Remove all user activities
192-
$classMapper->staticMethod('activity', 'where', 'user_id', $this->id)->delete();
191+
// Remove last activity association
192+
$this->lastActivity()->dissociate();
193+
$this->save();
193194

194195
// Remove all user tokens
195-
$classMapper->staticMethod('password_reset', 'where', 'user_id', $this->id)->delete();
196+
$this->activities()->delete();
197+
$this->passwordResets()->delete();
196198
$classMapper->staticMethod('verification', 'where', 'user_id', $this->id)->delete();
197-
198-
// TODO: remove any persistences
199+
$classMapper->staticMethod('persistence', 'where', 'user_id', $this->id)->delete();
199200

200201
// Delete the user
201-
$result = parent::forceDelete();
202+
$result = $this->forceDelete();
202203
} else {
203204
// Soft delete the user, leaving all associated records alone
204205
$result = parent::delete();

app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function write(array $record)
2828

2929
if (isset($record['extra']['user_id'])) {
3030
$user = $this->classMapper->staticMethod('user', 'find', $record['extra']['user_id']);
31-
$user->last_activity_id = $log->id;
31+
$user->lastActivity()->associate($log);
3232
$user->save();
3333
}
3434
}

app/sprinkles/account/src/Repository/PasswordResetRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace UserFrosting\Sprinkle\Account\Repository;
1111

12+
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface;
1213
use UserFrosting\Sprinkle\Account\Facades\Password;
1314

1415
/**
@@ -27,7 +28,7 @@ class PasswordResetRepository extends TokenRepository
2728
/**
2829
* {@inheritdoc}
2930
*/
30-
protected function updateUser($user, $args)
31+
protected function updateUser(UserInterface $user, $args)
3132
{
3233
$user->password = Password::hash($args['password']);
3334
// TODO: generate user activity? or do this in controller?

app/sprinkles/account/src/Repository/VerificationRepository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace UserFrosting\Sprinkle\Account\Repository;
1111

12+
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface;
13+
1214
/**
1315
* Token repository class for new account verifications.
1416
*
@@ -25,7 +27,7 @@ class VerificationRepository extends TokenRepository
2527
/**
2628
* {@inheritdoc}
2729
*/
28-
protected function updateUser($user, $args)
30+
protected function updateUser(UserInterface $user, $args)
2931
{
3032
$user->flag_verified = 1;
3133
// TODO: generate user activity? or do this in controller?

app/sprinkles/account/src/ServicesProvider/ServicesProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function register(ContainerInterface $container)
6969
$classMapper->setClassMapping('activity', 'UserFrosting\Sprinkle\Account\Database\Models\Activity');
7070
$classMapper->setClassMapping('password_reset', 'UserFrosting\Sprinkle\Account\Database\Models\PasswordReset');
7171
$classMapper->setClassMapping('verification', 'UserFrosting\Sprinkle\Account\Database\Models\Verification');
72+
$classMapper->setClassMapping('persistence', 'UserFrosting\Sprinkle\Account\Database\Models\Persistence');
7273

7374
return $classMapper;
7475
});

app/sprinkles/account/templates/forms/settings-profile.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</div>
2121
</div>
2222

23+
{% if 'locale' not in fields.hidden %}
2324
<div class="form-group">
2425
<label for="input-locale" class="control-label">{{translate("LOCALE")}}</label>
2526
<select id="input-locale" class="form-control js-select2" name="locale" {{page.visibility}}>
@@ -31,6 +32,7 @@
3132
</select>
3233
<p class="help-block">{{translate("LOCALE.ACCOUNT")}}.</p>
3334
</div>
35+
{% endif %}
3436
{% endblock %}
3537
</div>
3638
<div class="box-footer text-center">

0 commit comments

Comments
 (0)