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

Fix EZP-22095: eZ Star Rating does not work for anonymous #14

Merged
merged 1 commit into from Dec 19, 2013

Conversation

yannickroger
Copy link
Contributor

Link: https://jira.ez.no/browse/EZP-22095

Description

Since we added an antispam feature in 4.1, using star rating for anonymous user was not working anymore. This patch reintroduce the anonymous rating by using a new setting that bypasses the spam feature (some user might be in a spam free environment such as some intranets). It also makes sure to create sessions only when needed.

Tests

Manual tests

@bdunogier
Copy link
Member

Quick feedback...

  • you could factorize getting the INI setting to a well named protected method
  • if you need to enable 2 settings to get something working, maybe log an error if the settings are obviously incorrect

@@ -58,7 +58,10 @@ public static function rate( $args )

// Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
// to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
if ( class_exists( 'eZSession' ) && eZSession::userHasSessionCookie() !== true )
if ( class_exists( 'eZSession' ) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

while on it, class_exists( 'eZSession' ) can be removed

@dpobel
Copy link
Contributor

dpobel commented Dec 18, 2013

seems ok to me but the relation between UseUserSession, AllowAnonymousRating and the Session/ForceStart settings should be clarified because it's unclear to me if all combinations of those can work or not.

@yannickroger
Copy link
Contributor Author

@dpobel
The setting AllowAnonymousRating only desactivates the anti spam filter.

Regarding sessions :
If you enable UseUserSession: starrating will use sessions:

  • To avoid logged in users to vote more than once even after login in and out with different user (this behavior has not been modified).
  • To allow different anonymous users (identified by their sessions) to vote:
    • If Session/ForceStart is set to enabled: Existing sessions will be used
    • if Session/ForceStart is set to disabled: New sessions will be created for any user who starts rating content

@dpobel
Copy link
Contributor

dpobel commented Dec 19, 2013

+1

@@ -186,7 +188,8 @@ function userHasRated( $returnRatedObject = false )
*/
function store( $fieldFilters = null )
{
if ( $this->attribute( 'user_id' ) == eZUser::currentUserID() )
if ( $this->attribute( 'user_id' ) == eZUser::currentUserID() &&
eZINI::instance()->variable( 'eZStarRating', 'UseUserSession' ) === 'enabled' )
Copy link
Contributor

Choose a reason for hiding this comment

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

CS

if (
    $this->attribute( 'user_id' ) == eZUser::currentUserID()
    && eZINI::instance()->variable( 'eZStarRating', 'UseUserSession' ) === 'enabled' 
)

@lolautruche
Copy link
Contributor

Looks good, besides my comments +1

yannickroger added a commit that referenced this pull request Dec 19, 2013
Fix EZP-22095: eZ Star Rating does not work for anonymous
@yannickroger yannickroger merged commit fc5ffd5 into master Dec 19, 2013
@yannickroger yannickroger deleted the ezp-22095-anonymous_session branch December 19, 2013 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants