Hi Liang, I pretty much followed the instructions provided by Alec in his replies from April1 and April 3. I’ve included the corrected code below for the affected functions in the 2 files PKPOAIDAO.inc.php & OAIDAO.inc.php, I didn’t share entire files as we have quite a bit of custom code, in our OJS.
Hope this helps.
\lib\pkp\classes\oai\PKPOAIDAO.inc.php
function getEarliestDatestamp($setIds = array()) {
$result = $this->_getRecordsRecordSet($setIds, null, null, null, null, 'last_modified ASC');
if ($result->RecordCount() != 0) {
$row = $result->GetRowAssoc(false);
$returner = $this->_returnRecordFromRow($row);
} else $returner = null;
$result->Close();
unset($result);
return OAIUtils::UTCtoTimestamp($returner->datestamp, false);
}
function recordExists($dataObjectId, $setIds = array()) {
return $this->getRecord($dataObjectId, $setIds)?true:false;
}
function &getRecord($dataObjectId, $setIds = array()) {
$params = $this->getOrderedRecordParams($dataObjectId, $setIds);
$result = $this->_getRecordsRecordSet($setIds, null, null, null, $dataObjectId);
if ($result->RecordCount() != 0) {
$row =& $result->GetRowAssoc(false);
$returner =& $this->_returnRecordFromRow($row);
} else $record = null;
$result->Close();
unset($result);
return $returner;
}
\classes\oai\ojs\OAIDAO.inc.php
function _getRecordsRecordSet($setIds, $from, $until, $set, $submissionId = null, $orderBy = 'journal_id, article_id') {
$journalId = array_shift($setIds);
$sectionId = array_shift($setIds);
$params = array();
if ($journalId) $params[] = (int) $journalId;
if ($sectionId) $params[] = (int) $sectionId;
if ($submissionId) $params[] = (int) $submissionId;
if ($journalId) $params[] = (int) $journalId;
if ($sectionId) $params[] = (int) $sectionId;
if (isset($set)) $params[] = $set;
if ($submissionId) $params[] = (int) $submissionId;
$result = $this->retrieve(
'SELECT LEAST(a.last_modified, i.last_modified) AS last_modified,
a.article_id AS article_id,
j.journal_id AS journal_id,
s.section_id AS section_id,
i.issue_id,
NULL AS tombstone_id,
NULL AS set_spec,
NULL AS oai_identifier
FROM
published_articles pa
JOIN articles a ON (a.article_id = pa.article_id)
JOIN issues i ON (i.issue_id = pa.issue_id)
JOIN sections s ON (s.section_id = a.section_id)
JOIN journals j ON (j.journal_id = a.journal_id)
WHERE i.published = 1 AND j.enabled = 1 AND a.status <> ' . STATUS_DECLINED . '
' . ($journalId?' AND j.journal_id = ?':'') . '
' . ($sectionId?' AND s.section_id = ?':'') . '
' . ($from?' AND LEAST(a.last_modified, i.last_modified) >= ' . $this->datetimeToDB($from):'') . '
' . ($until?' AND GREATEST(a.last_modified, i.last_modified) <= ' . $this->datetimeToDB($until):'') . '
' . ($submissionId?' AND a.article_id = ?':'') . '
UNION
SELECT dot.date_deleted AS last_modified,
dot.data_object_id AS article_id,
tsoj.assoc_id AS assoc_id,
tsos.assoc_id AS section_id,
NULL AS issue_id,
dot.tombstone_id,
dot.set_spec,
dot.oai_identifier
FROM data_object_tombstones dot
JOIN data_object_tombstone_oai_set_objects tsoj ON ' . (isset($journalId) ? '(tsoj.tombstone_id = dot.tombstone_id AND tsoj.assoc_type = ' . ASSOC_TYPE_JOURNAL . ' AND tsoj.assoc_id = ?)' : 'tsoj.assoc_id = null') . '
JOIN data_object_tombstone_oai_set_objects tsos ON ' . (isset($sectionId) ? '(tsos.tombstone_id = dot.tombstone_id AND tsos.assoc_type = ' . ASSOC_TYPE_SECTION . ' AND tsos.assoc_id = ?)' : 'tsos.assoc_id = null') . '
WHERE 1=1
' . (isset($set)?' AND dot.set_spec = ?':'') . '
' . ($from?' AND dot.date_deleted >= ' . $this->datetimeToDB($from):'') . '
' . ($until?' AND dot.date_deleted <= ' . $this->datetimeToDB($until):'') . '
' . ($submissionId?' AND dot.data_object_id = ?':'') . '
ORDER BY ' . $orderBy,
$params
);
return $result;
}
Regards
Jannie