BePressImport Plugin Error: Duplicate entry key

I’ve noticed another user having a similar problem here: Bepress import error when doing a second import


Difference is I am not doing a second import, this is an initial import. The user also suggested to comment out the following from Which I did but still the same error.

/* function add()  */ 
public function add($submissionFile, $request) {
       /*  .....  */
		$request, $submission,
			'fileStage' => $submissionFile->getFileStage(),
			'submissionFileId' => $submissionFile->getId(),
			'fileId' => $submissionFile->getData('fileId'),
			'submissionId' => $submissionFile->getData('submissionId'),
			'username' => $user->getUsername(),
			'name' => $submissionFile->getLocalizedData('name'),
     /* ......... */

See system information below

Issues table

I’ve arrowed down where the issue is coming from…

The insert statement is made to the custom_issue_orders table; however we are inserting the very same issueIds that are retrieved from the previous query (see getPublishedIssues). The inner join is checking for existing and matching issueIds on both the issue and custom_issue_orders tables. Thus inserting the very same issueId as we iterate over the previous call would immediately error.

Am I missing something here in the logic or is this a flaw?

/* */

function setDefaultCustomIssueOrders($journalId) {
	$publishedIssues = $this->getPublishedIssues($journalId);
	for ($i=1; $issue = $publishedIssues->next(); $i++) {
        /* error below */
		$this->insertCustomIssueOrder($journalId, $issue->getId(), $i);  

function insertCustomIssueOrder($journalId, $issueId, $seq) {
		'INSERT INTO custom_issue_orders (issue_id, journal_id, seq) VALUES (?, ?, ?)',
		[(int) $issueId, (int) $journalId, $seq]

function getPublishedIssues($journalId, $rangeInfo = null) {
	$result = $this->retrieveRange(
		'SELECT i.* FROM issues i LEFT JOIN custom_issue_orders o ON (o.issue_id = i.issue_id) WHERE i.journal_id = ? AND i.published = 1 ORDER BY o.seq ASC, i.current DESC, i.date_published DESC',
		[(int) $journalId], $rangeInfo

	return new DAOResultFactory($result, $this, '_returnIssueFromRow');

I also noticed that the custom_issue_orders table does not auto_incr the issueIds.

My issue was with the inserts to log files. That is with an issue keys. Do you try to import to an existing issue? I newer tried that but did full import of an issue in one import run.

I edited the answer after looking at the code a bit more.