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

Forcing a unique login per user row, making sure code can handle it #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kernel/classes/datatypes/ezuser/ezusertype.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ function storeObjectAttribute( $contentObjectAttribute )
else
{
// No "draft" for version 1 to avoid regression for existing code creating new users.
if ( $contentObjectAttribute->attribute( 'version' ) == '1' )
if (
$contentObjectAttribute->attribute( 'version' ) == '1' &&
! $contentObjectAttribute->hasValidationError()
)
{
$user->store();
$contentObjectAttribute->setContent( $user );
Expand Down Expand Up @@ -386,6 +389,7 @@ function objectAttributeContent( $contentObjectAttribute )

if ( !empty( $serializedDraft ) )
{
if( !$user ) $user = new eZUser();
$user = $this->updateUserDraft( $user, $serializedDraft );
}

Expand Down
7 changes: 7 additions & 0 deletions update/database/mysql/lovestack/4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# You may already have non-unique values in your ezuser database table.
# Use following SQL statement to test and identify those instances:
# SELECT login, COUNT(*) AS instances FROM ezuser GROUP BY login HAVING instances > 1;
# You would need to manually resolve those duplicate rows - for example by editing the login values
# Otherwise the following SQL statements will fail.
DROP INDEX ezuser_login on ezuser;
CREATE UNIQUE INDEX ezuser_login ON ezuser (login);