PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
21 Oct 2024

Pull Request for Issue # .
on installation joomla create a SuperUser whose id is generated random(1,1000)

but with postgresql the relative sequence #__users_id_seq is not setted is still 1, so as soon we create an user
whose id is equal to the id created for the Super User we got duplicate key value violates unique constraint "jos_users_pkey

Summary of Changes

set the relative sequence #__users_id_seq after the super user creation

Testing Instructions

apply pull PR
and run cypress install/installation.cy.js

and the run this test:

scripts/create 52 pgsql
cat > branch_52/tests/System/integration/install/duplicate.cy.js <<EOF
describe('Test duplicate key value error', () => {
  it('in creating 1,000 users', () => {
    for (let i = 1; i <= 1000; i++) {
        cy.db_createUser({username: \`test user \${i}\` });
    }
  });
});
EOF

scripts/test 52 system install/duplicate.cy.js

Actual result BEFORE applying this Pull Request

duplicate key value violates unique constraint "jos_users_pkey

Expected result AFTER applying this Pull Request

no more duplicate error

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar alikon alikon - open - 21 Oct 2024
avatar alikon alikon - change - 21 Oct 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Oct 2024
Category Installation
5799c3c 21 Oct 2024 avatar alikon cs
avatar alikon alikon - change - 21 Oct 2024
Labels Added: PR-5.2-dev
avatar alikon alikon - change - 21 Oct 2024
The description was changed
avatar alikon alikon - edited - 21 Oct 2024
avatar rdeutz
rdeutz - comment - 21 Oct 2024

Good find!

avatar muhme
muhme - comment - 22 Oct 2024

✅ Tested succesfully on macOS 👍

  • Installed PR 44324 with Patch Tester
  • Testing requires the installation step, as the fix applies during the installation step. Therefore, I used:
scripts/test 52 system tests/System/integration/install/Installation.cy.js,tests/System/integration/install/duplicate.cy.js
  • Additionally, all remaining System Tests (without the installation step) passed:
scripts/test 52 system


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44324.
avatar laoneo laoneo - change - 22 Oct 2024
Title
[5] synch the sequence for pgsql
[5] Sync the sequence for pgsql after the root user is created
avatar laoneo laoneo - edited - 22 Oct 2024
avatar richard67
richard67 - comment - 22 Oct 2024

@muhme Could you repeat your test to make sure my suggested changes did not break anything? And if successful, mark your test result in the issue tracker with the blue "Text this" button in the PR details? Thanks in advance.

avatar richard67 richard67 - test_item - 22 Oct 2024 - Tested successfully
avatar richard67
richard67 - comment - 22 Oct 2024

I have tested this item ✅ successfully on a2feb76

I haven't tested as described with Cypress. Instead of this, I have done following.

I've made a new installation of a clean 5.2-dev branch using an empty PostgreSQL database (of course after composer install and npm ci).

Directly after that (no need to login to the backend) I have checked the ID of the superuser and the last value of the "#__users_id_seq" sequence with phpPgAdmin. (Last value is a misleading term because in fact is is the next value.)

Result: The superuser's ID has a value between 1 and 1000, e.g. 362. The last value of the sequence is 1.

Then I have done the same with the branch of this PR under the same starting conditions (clean branch, composer install, npm ci, install into empty PostgreSQL DB).

Result: The superuser's ID has a value between 1 and 1000, e.g. 362. The last value of the sequence is this ID value plus 1, e.g. 363.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44324.

avatar richard67
richard67 - comment - 22 Oct 2024

Additional test: After the installation and the checks in phpPgAdmin I logged in to the administrator and have created a new user.

Without the PR that new user has ID = 1 (one).

With the PR the new user has ID = ID of the super user plus one.

avatar muhme muhme - test_item - 22 Oct 2024 - Tested successfully
avatar muhme
muhme - comment - 22 Oct 2024

I have tested this item ✅ successfully on a2feb76

On macOS with JBT created 5.2-dev branch installation with additional test case and run the tests to see the problem:

scripts/create 52 pgsql
cat > branch_52/tests/System/integration/install/duplicate.cy.js <<EOF
describe('Test duplicate key value error', () => {
  it('in creating 1,000 users', () => {
    for (let i = 1; i <= 1000; i++) {
        cy.db_createUser({username: \`test user \${i}\` });
    }
  });
});
EOF
scripts/test 52 system tests/System/integration/install/Installation.cy.js,tests/System/integration/install/duplicate.cy.js

Problem seen:

  1) Test duplicate key value error
       in creating 1,000 users:
     CypressError: `cy.task('queryDB')` failed with the following error:

> duplicate key value violates unique constraint "jos52_users_pkey"

Checked PR with recreating 5.2-dev branch with additional test case and installing patch tester, applying PR 44324 and running same tests again plus all remaining System Tests:

scripts/create recreate 52 pgsql
scripts/patchtester 52
# Applying PR 44324 in http://host.docker.internal:7052/administrator/index.php?option=com_patchtester
cat > branch_52/tests/System/integration/install/duplicate.cy.js <<EOF
describe('Test duplicate key value error', () => {
  it('in creating 1,000 users', () => {
    for (let i = 1; i <= 1000; i++) {
        cy.db_createUser({username: \`test user \${i}\` });
    }
  });
});
EOF
scripts/test 52 system tests/System/integration/install/Installation.cy.js,tests/System/integration/install/duplicate.cy.js
scripts/test 52 system

One timeout error and repeated this single test step:

scripts/test system 52 administrator/components/com_cpanel/CPanel.cy.js

All tests are passed successfully 👍


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44324.

avatar laoneo laoneo - change - 22 Oct 2024
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-10-22 11:47:04
Closed_By laoneo
avatar laoneo laoneo - close - 22 Oct 2024
avatar laoneo laoneo - merge - 22 Oct 2024
avatar laoneo
laoneo - comment - 22 Oct 2024

Thanks you guys for the extensive testing and @alikon for fixing this long standing bug.

Add a Comment

Login with GitHub to post a comment