Skip to content

Commit

Permalink
Merge pull request #8943 from bozana/8940
Browse files Browse the repository at this point in the history
#8940 fix clearIssueObjectsPubIds and saving URNs
  • Loading branch information
bozana committed Apr 28, 2023
2 parents bd61fc9 + eac19f7 commit 2e69b0b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
17 changes: 9 additions & 8 deletions classes/plugins/PKPPubIdPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function manage($args, $request)
* Get the public identifier.
*
* @param object $pubObject
* Submission, Representation, SubmissionFile + OJS Issue
* Publication, Representation, SubmissionFile
*
* @return string
*/
Expand Down Expand Up @@ -321,7 +321,7 @@ public function verifyData($fieldName, $fieldValue, $pubObject, $contextId, &$er
}
$newPubId = $this->constructPubId($pubIdPrefix, $fieldValue, $contextId);

if (!$this->checkDuplicate($newPubId, $pubObject->getId(), get_class($pubObject), $contextId)) {
if (!$this->checkDuplicate($newPubId, get_class($pubObject), $pubObject->getId(), $contextId)) {
$errorMsg = $this->getNotUniqueErrorMsg();
return false;
}
Expand Down Expand Up @@ -351,7 +351,6 @@ public function getDAOs()
{
return [
Repo::publication()->dao,
Repo::submission()->dao,
Application::getRepresentationDAO(),
Repo::submissionFile()->dao,
];
Expand All @@ -361,7 +360,7 @@ public function getDAOs()
* Can a pub id be assigned to the object.
*
* @param object $pubObject
* Submission, Representation, SubmissionFile + OJS Issue
* Publication, Representation, SubmissionFile, OJS Issue, OMP Chapter
*
* @return bool
* false, if the pub id contains an unresolved pattern i.e. '%' or
Expand Down Expand Up @@ -417,13 +416,15 @@ public function addToSchema($hookName, $params)
* @see PKPPubIdPlugin::addToSchema()
*
* @param string $hookName
* @param array $params
* @param DAO $dao
* @param array $additionalFields
*
* @return bool
*/
public function getAdditionalFieldNames($hookName, $params)
public function getAdditionalFieldNames($hookName, $dao, &$additionalFields)
{
$fields = & $params[1];
foreach (array_merge($this->getFormFieldNames(), $this->getDAOFieldNames()) as $fieldName) {
$fields[] = $fieldName;
$additionalFields[] = $fieldName;
}
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions classes/plugins/PKPPubIdPluginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ public function clearPubId($contextId, $pubIdPlugInClassName, $pubObject)
// delete the pubId from the DB
$dao = $pubObject->getDAO();
$pubObjectId = $pubObject->getId();
if ($pubObject instanceof SubmissionFile) {
$pubObjectId = $pubObject->getId();
}
$dao->deletePubId($pubObjectId, $pubIdPlugin->getPubIdType());
// set the object setting/data 'pub-id::...' to null, in order
// not to be considered in the DB object update later in the form
Expand Down
2 changes: 1 addition & 1 deletion classes/publication/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function deletePubId($pubObjectId, $pubIdType)
{
DB::table($this->settingsTable)
->where('publication_id', (int) $pubObjectId)
->where('setting_name', '=', $pubIdType)
->where('setting_name', '=', 'pub-id::' . $pubIdType)
->delete();
}

Expand Down
8 changes: 8 additions & 0 deletions classes/submissionFile/SubmissionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ public function getDoi(): ?string
return $doiObject->getData('doi');
}
}

/**
* @copydoc \PKP\core\DataObject::getDAO()
*/
public function getDAO(): DAO
{
return Repo::submissionFile()->dao;
}
}

if (!PKP_STRICT_MODE) {
Expand Down

0 comments on commit 2e69b0b

Please sign in to comment.