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
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

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: Baidu [Spider] and 1 guest