OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



article_files table has duplicate primary key entries

OJS development discussion, enhancement requests, third-party patches and plug-ins.

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

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

article_files table has duplicate primary key entries

Postby barbarah » Fri Apr 22, 2011 1:53 pm

I just noticed that through the course of the submission/review/copyedit process, OJS sometimes creates multiple article_files database records with the same file_id. Since file_id is the primary key for the table, this means there is no enforced unique identifier for these records. For example, we have 5 records with file_id = 49 in our ojs database:

mysql> select file_id, revision, type, article_id, file_name, file_type, original_file_name from article_files where file_id = 49;
+---------+----------+---------------------+------------+----------------+--------------------+---------------------------------------+
| file_id | revision | type | article_id | file_name | file_type | original_file_name |
+---------+----------+---------------------+------------+----------------+--------------------+---------------------------------------+
| 49 | 1 | submission/review | 13 | 13-49-1-RV.doc | application/msword | 13-48-1-SM.doc |
| 49 | 2 | submission/copyedit | 13 | 13-49-2-CE.doc | application/msword | Announcing the latest XTF release.doc |
| 49 | 3 | submission/copyedit | 13 | 13-49-3-CE.doc | application/msword | mellonMATC2009Final.doc |
| 49 | 4 | submission/copyedit | 13 | 13-49-4-CE.doc | application/msword | mellonMATC2009Final.doc |
| 49 | 5 | submission/copyedit | 13 | 13-49-5-CE.doc | application/msword | mellonMATC2009Final.doc |
+---------+----------+---------------------+------------+----------------+--------------------+---------------------------------------+
5 rows in set (0.00 sec)


I searched the forum to see if this issue has been raised before, but I can't find any info on it (it only seems to have come up when people try to migrate their database and postgresql/mysql throws an error since the primary key rule is violated by the data). Have other people run into this problem? It seems like this could be a big issue, for example when the code tries to find a record based on its file_id. How does OJS know which record to use? We've noticed some problems with uploading files before, and are wondering if this could be part of the problem?

I also see that in the articles table, the revised_file_id, review_file_id and editor_file_id fields are links to the article_files table on file_id. But this link is broken/made ambiguous since there can be more than 1 article_files records with a given file_id.

Any thoughts/feedback appreciated. Thanks!
barbarah
 
Posts: 27
Joined: Thu Mar 24, 2011 1:25 pm
Location: California Digital Library, Oakland, California

Re: article_files table has duplicate primary key entries

Postby mcrider » Wed Apr 27, 2011 12:04 pm

Hi Barbara,

Each row in the article_files table is identified by a (file_id, revision) tuple. In the case of other tables referring to files in the article_files table, the code will always get the latest revision of that file.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: article_files table has duplicate primary key entries

Postby barbarah » Wed Apr 27, 2011 3:24 pm

Hi Matt,

Thanks for your reply. OK, that's what I figured out after I posted; good to have confirmation though. Not an ideal situation, but workable :-)

-Barbara
barbarah
 
Posts: 27
Joined: Thu Mar 24, 2011 1:25 pm
Location: California Digital Library, Oakland, California


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 3 guests

cron