OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



DB Error: Duplicate entry 'xx' for key 1

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

DB Error: Duplicate entry 'xx' for key 1

Postby gbarrer » Mon May 11, 2009 2:46 pm

I'm having trouble when I try to create a new issue on OJS 2.2. Here the debug output.

DB Error: Duplicate entry '1' for key 2
Stack Trace:
File: xxx/revistas/classes/issue/IssueDAO.inc.php line 252
Function: DAO->update("INSERT INTO issues (journal_id, volume, number,
year, publis...", Array(14))

File: xxx/revistas/classes/issue/form/IssueForm.inc.php line 348
Function: IssueDAO->insertIssue(Object(Issue))

File: xxx/revistas/pages/editor/IssueManagementHandler.inc.php
line 136
Function: IssueForm->execute()

File: xxx/revistas/pages/editor/EditorHandler.inc.php line 468
Function: IssueManagementHandler::saveIssue()

File: (unknown) line (unknown)
Function: EditorHandler::saveIssue(Array(0))

File: xxx/revistas/index.php line 58
Function: call_user_func(Array(2), Array(0))

File: xxx/revistas/index.php line 69
Function: handleRequest()

I already followed this note viewtopic.php?f=8&t=2885&p=11059&hilit=insert+issue#p11059


ALTER TABLE issues DROP INDEX issues_public_issue_id;# Linii afectate: 1
CREATE UNIQUE INDEX issues_public_issue_id ON issues (public_issue_id, journal_id);# Linii afectate: 1

What is wrong?


Thanks in advance

Gabriel Barrera
Universidad Javeriana - Colombia

Gabriel Barrera
Universidad Javeriana - Colombia
http://tecnocacharrero.blogspot.com/search/label/PKP
Last edited by gbarrer on Fri Jun 05, 2009 2:20 pm, edited 1 time in total.
gbarrer
 
Posts: 4
Joined: Fri Jan 11, 2008 9:15 am

Re: DB Error: Duplicate entry 'xx' for key 1

Postby jmacgreg » Wed May 13, 2009 10:36 am

Hi Gabriel,

Are you able to try and use globally unique issue IDs, or are you able to turn the public issue ID option off?

Cheers,
James
jmacgreg
 
Posts: 4186
Joined: Tue Feb 14, 2006 10:50 am

Re: DB Error: Duplicate entry 'xx' for key 1

Postby farschidus » Thu May 14, 2009 6:19 am

Hi James,

I got a problem with this error message too. But I found the problem in database. Our OJS website server attacked by a hacker couple a weeks ago and I forced to back it DB up and two folders (files and public) and made a fresh installation. When I did this error message showed up:

Duplicate entry 'PASSWORD_RESET_CONFIRM-en_US' for key 1

Then I installed OJS again with new database and the error is gone. I want to save my data in my old DB. what should I do?

Kind Regards.
farschidus
 
Posts: 12
Joined: Thu May 14, 2009 5:59 am
Location: Tehran, Iran

Re: DB Error: Duplicate entry 'xx' for key 1

Postby gbarrer » Thu May 14, 2009 8:06 am

Thanks James.

Journal Editor tried to use a unique identifier and now he can create new issues.

Thanks a lot.

Gabriel Barrera
Universidad Javeriana - Colombia
http://tecnocacharrero.blogspot.com/search/label/PKP
Last edited by gbarrer on Fri Jun 05, 2009 2:20 pm, edited 1 time in total.
gbarrer
 
Posts: 4
Joined: Fri Jan 11, 2008 9:15 am

Re: DB Error: Duplicate entry 'xx' for key 1

Postby asmecher » Fri May 15, 2009 3:38 pm

Hi Farshid,

Are you trying to restore your existing installation (e.g. database and all) from backup? If so, you don't need to run the installer -- just set "Installed" to "On" in config.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: DB Error: Duplicate entry 'xx' for key 1

Postby farschidus » Sat May 16, 2009 11:19 pm

Hi Alec,

Thank you very much. I found the solution before your reply. but after two days the website was down again. I think the hacker set script in my database and when I restore my database it generates his malicious script into all of php files. The script is a <iframe> generator that put an iframe in bottom of my php pages and open his address into it (it's a china address). And insert a bunch of php script in top of page.
Let me know if it helps to copy my index.php.
Q.What table I should look in DB for cleanup?

Thanks a lot.
farschidus
 
Posts: 12
Joined: Thu May 14, 2009 5:59 am
Location: Tehran, Iran

Re: DB Error: Duplicate entry 'xx' for key 1

Postby asmecher » Sun May 17, 2009 7:17 am

Hi Farshid,

I don't think this is likely to come from the database -- most likely your PHP file permissions are too open, and an automatic scan using some PHP vulnerability is adding the code. Find out what user account PHP scripts run under (e.g. if you're using mod_php, it'll probably be the "apache" user) and make sure that account doesn't have permission to modify your PHP scripts.

To track down the vulnerability, look at the date modified for your PHP scripts to find out when the vulnerability was installed. Then try to correlate that against a request in your web server log. You'll probably find a malicious request there. We've never had anything like this traced back to OJS, but as always, security requires vigilance -- please report what you find.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: DB Error: Duplicate entry 'xx' for key 1

Postby farschidus » Sun May 17, 2009 8:02 am

Thanks Alec,

I will let you know asa I found the problem.

Regards.
farschidus
 
Posts: 12
Joined: Thu May 14, 2009 5:59 am
Location: Tehran, Iran

Re: DB Error: Duplicate entry 'xx' for key 1

Postby farschidus » Thu May 21, 2009 1:41 am

Hi again,

I contacted the hosting support about the issue and he replied:

Hello Farshid,

Does the account host any open source software? In 99% of the cases, the hacker is able to get a hold of the account by using open source software such as Joomla, wordpress, etc. that is out dated. Or, the customer is using some custom modifications which are not written properly and allow the hacker to exploit the software. In any case, the issue is caused directly as a result of the php scripts allowing the hacker to gain access to the account. What we recommend to our users at that point is to completely remove the account and recreate. Then, reload the latest software, do not use mods that you don't know about and make sure to not install any software that you are not using.

The response from the webmaster in regards to mod_php or php permissions being too open don't apply as we run PHP as CGI and permissions above 755 will not work
Regards


What you think?

Just another problem Alec, When I deleted the ojs infected files and replaced them with originals. I can't login with my previous users. I just had to login with admin and edit users passwords to work again. I wonder where is users passwords saves. doesn't they store in database?
farschidus
 
Posts: 12
Joined: Thu May 14, 2009 5:59 am
Location: Tehran, Iran

Re: DB Error: Duplicate entry 'xx' for key 1

Postby asmecher » Thu May 21, 2009 6:04 am

Hi Farshid,

Yes, passwords are stored in the database, but there are two options for encryption (configured in config.inc.php) and I suspect that's what's changed.

Your ISP's comment is correct -- typically it'll be an outdated copy of something like phpBB or Drupal that causes the problem. These have very wide install bases, making them good targets for attack. Automated scans look for old copies of the software, and when they find it, they automatically do things like install modifications on any PHP or HTML on the server that the scan has permission to modify. Again, you can typically track it down by looking at the date modified and then correlating it against your access log.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: DB Error: Duplicate entry 'xx' for key 1

Postby ahmadhelmy » Sat Oct 05, 2013 9:33 pm

This problem cause error in your MySQL database table. To fix this problem you must have a root account to access your MySQL database or you can fix in from your phpmyadmin.
so, you have 2 ways to fix this problem.

Firts way :
From phpmyadmin you can fix it by following this instruction:
1. Login to your phpmyadmin account.
2. Chose your ojs database name then click or open the database.
3. Chose or click your table name where the error is happen. if your "sessions" table is error, so you click your "sessions" table.
4. Then at the top of link you can chose or click "Operations"
5. Then in column "Table maintenance" you can click "Repair table" to repair your error table.
6. Done
Hope this can help you.
Sorry my english is bad :)
ahmadhelmy
 
Posts: 1
Joined: Sat Oct 05, 2013 9:16 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 2 guests