Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#8940 fix clearIssueObjectsPubIds and saving URNs #8943

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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