Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve event filters #304

Merged
merged 8 commits into from
Nov 24, 2017

Conversation

michael-e
Copy link
Member

This PR improves event filters as described in #303.

Additionally, the last commit (02aac90) adds additional constants to the MemberEventMessages class and implements error codes for all Event Filters. Please note that adding these error codes to Filters (as opposed to Events) might be controversial, so I am open to feedback!

@michael-e michael-e requested review from brendo and nitriques November 1, 2017 23:53
@@ -703,7 +703,7 @@ public function appendFilter($context) {
);
}

if(!FieldManager::isFieldUsed(self::getFieldType('authentication'))) {
if(FieldManager::isFieldUsed(self::getFieldType('authentication'))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make it show "always", but only if a authentication field is used. It was a bug ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Yes, I can only suspect that this was a bug, introduced by accident. The filter will call the filter_UpdatePasswordLogin function, which is completely useless without an authentication field. So the filter itself has been useless all the time, and I don't consider this a breaking change but a bugfix. (Please, confirm! I don't want to break stuff, of course.)

For the same reason showing the filter is only useful if an authentication field exists, so IMHO "always if the field exists" is enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM then!

Copy link
Member Author

@michael-e michael-e Nov 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I found the misunderstanding. In #44 (comment) @jensscherbl said:

Added this as a filter (Members: Login), which is only available if no activation is needed. Just like @brendo suggested.

So the idea was to only show the filter if no activation field exists. But actually he tested for the authentication field. I don't know why nobody ever noticed this.

(I don't think that we need to test for the activation field. It's up to the developer to use the the filter (and see if it works). The filter just attempts to do what the name says: Log the Member in.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

return;
}

if (is_null($this->section->getFieldHandle('authentication'))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do ! instead of is_null ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design getFieldHandle will return null or a string, so why do you prefer !?

I'd prefer to be consistent with the rest of the code. If you search the extension for $this->section->getFieldHandle, you will see that is_null is always used to test the return value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we need to change how these return values are tested, I suggest to open another issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na it's ok.


$member_id = null;
if (isset($_POST['fields'][$this->section->getFieldHandle('authentication')]['validate'])) {
$password = Symphony::Database()->cleanValue(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to clean the password, as it will be hashed anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 3216572

@michael-e
Copy link
Member Author

I will wait a bit with merging, because:

  1. Maybe @brendo joins the party.
  2. An interesting aspect has popped up.

This commit adds information about the "immediate login after registration" procedure and some hints about the (execution) order of Member info and events/filters.
@michael-e
Copy link
Member Author

IMHO this can be pulled now. #303 can be closed then. I suggest to release 1.10.0, because we have new features.

@michael-e michael-e mentioned this pull request Nov 24, 2017
@michael-e michael-e assigned nitriques and unassigned michael-e Nov 24, 2017
@nitriques nitriques merged commit a4c4ded into symphonycms:integration Nov 24, 2017
@michael-e michael-e deleted the improve-event-filters branch November 25, 2017 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants