Skip to content

Commit

Permalink
Merge pull request #543 from jonasraoni/feature/main/8333-add-remaini…
Browse files Browse the repository at this point in the history
…ng-fks

Feature/main/8333 add remaining fks
  • Loading branch information
jonasraoni authored Jul 24, 2024
2 parents 2950ce4 + 306f602 commit 8783170
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 30 deletions.
2 changes: 1 addition & 1 deletion classes/file/PublicFileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PublicFileManager extends PKPPublicFileManager
/**
* @copydoc PKPPublicFileManager::getContextFilesPath()
*/
public function getContextFilesPath($contextId)
public function getContextFilesPath(int $contextId)
{
return Config::getVar('files', 'public_files_dir') . '/contexts/' . (int) $contextId;
}
Expand Down
33 changes: 33 additions & 0 deletions classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php
*
* Copyright (c) 2023 Simon Fraser University
* Copyright (c) 2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I8333_AddMissingForeignKeys
*
* @brief Describe upgrade/downgrade operations for introducing foreign key definitions to existing database relationships.
*/

namespace APP\migration\upgrade\v3_5_0;

class I8333_AddMissingForeignKeys extends \PKP\migration\upgrade\v3_5_0\I8333_AddMissingForeignKeys
{
protected function getContextTable(): string
{
return 'servers';
}

protected function getContextKeyField(): string
{
return 'server_id';
}

protected function getContextSettingsTable(): string
{
return 'server_settings';
}
}
13 changes: 4 additions & 9 deletions classes/oai/ops/OAIDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@ public function __construct()
/**
* Cached function to get a server
*
* @param int $serverId
*
* @return object
*/
public function &getServer($serverId)
public function getServer(int $serverId)
{
if (!isset($this->serverCache[$serverId])) {
$this->serverCache[$serverId] = $this->serverDao->getById($serverId);
}
return $this->serverCache[$serverId];
return $this->serverCache[$serverId] ??= $this->serverDao->getById($serverId);
}

/**
Expand All @@ -92,14 +87,14 @@ public function &getSection($sectionId)
/**
* Return hierarchy of OAI sets (servers plus server sections).
*
* @param int $serverId
* @param int $offset
* @param int $total
*
* @return array OAISet
*
* @hook OAIDAO::getServerSets [[$this, $serverId, $offset, $limit, $total, &$sets]]
*/
public function &getServerSets($serverId, $offset, $limit, &$total)
public function &getServerSets(int $serverId, $offset, $limit, &$total)
{
if (isset($serverId)) {
$servers = [$this->serverDao->getById($serverId)];
Expand Down
6 changes: 4 additions & 2 deletions classes/oai/ops/ServerOAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class ServerOAI extends OAI
/** @var Server associated server object */
public $server;

/** @var int|null Server ID; null if no server */
public $serverId;
public ?int $serverId;

/** @var OAIDAO DAO for retrieving OAI records/tokens from database */
public $dao;
Expand Down Expand Up @@ -182,6 +181,7 @@ public function record($identifier)

/**
* @copydoc OAI::records()
*
* @hook ServerOAI::records [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]]
*/
public function records($metadataPrefix, $from, $until, $set, $offset, $limit, &$total)
Expand All @@ -201,6 +201,7 @@ public function records($metadataPrefix, $from, $until, $set, $offset, $limit, &

/**
* @copydoc OAI::identifiers()
*
* @hook ServerOAI::identifiers [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]]
*/
public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limit, &$total)
Expand All @@ -220,6 +221,7 @@ public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limi

/**
* @copydoc OAI::sets()
*
* @hook ServerOAI::sets [[$this, $offset, $limit, &$total, &$sets]]
*/
public function sets($offset, $limit, &$total)
Expand Down
4 changes: 1 addition & 3 deletions classes/publication/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ class Publication extends PKPPublication
/**
* Get the URL to a localized cover image
*
* @param int $contextId
*
* @return string
*/
public function getLocalizedCoverImageUrl($contextId)
public function getLocalizedCoverImageUrl(int $contextId)
{
$coverImage = $this->getLocalizedData('coverImage');

Expand Down
8 changes: 4 additions & 4 deletions classes/section/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getAbbrev(?string $locale): string|array|null
return $this->getData('abbrev', $locale);
}

public function setAbbrev(string|array $abbrev, string $locale = null): void
public function setAbbrev(string|array $abbrev, ?string $locale = null): void
{
$this->setData('abbrev', $abbrev, $locale);
}
Expand All @@ -51,7 +51,7 @@ public function getPolicy(?string $locale): string|array|null
return $this->getData('policy', $locale);
}

public function setPolicy(string|array $policy, string $locale = null): void
public function setPolicy(string|array $policy, ?string $locale = null): void
{
$this->setData('policy', $policy, $locale);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public function getIdentifyType(?string $locale): string|array|null
/**
* Set string identifying type of items in this section.
*/
public function setIdentifyType(string|array $identifyType, string $locale = null): void
public function setIdentifyType(string|array $identifyType, ?string $locale = null): void
{
$this->setData('identifyType', $identifyType, $locale);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public function getDescription(?string $locale): string|array|null
/**
* Set series description.
*/
public function setDescription(string|array $description, string $locale = null): void
public function setDescription(string|array $description, ?string $locale = null): void
{
$this->setData('description', $description, $locale);
}
Expand Down
6 changes: 2 additions & 4 deletions classes/server/ServerDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ public function getTitles($enabledOnly = false)
/**
* Delete the public IDs of all publishing objects in a server.
*
* @param int $serverId
* @param string $pubIdType One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
*/
public function deleteAllPubIds($serverId, $pubIdType)
public function deleteAllPubIds(int $serverId, $pubIdType)
{
Repo::galley()->dao->deleteAllPubIds($serverId, $pubIdType);
Repo::submissionFile()->dao->deleteAllPubIds($serverId, $pubIdType);
Expand All @@ -93,7 +92,6 @@ public function deleteAllPubIds($serverId, $pubIdType)
* Check whether the given public ID exists for any publishing
* object in a server.
*
* @param int $serverId
* @param string $pubIdType One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
Expand All @@ -106,7 +104,7 @@ public function deleteAllPubIds($serverId, $pubIdType)
* @return bool
*/
public function anyPubIdExists(
$serverId,
int $serverId,
$pubIdType,
$pubId,
$assocType = MetadataTypeDescription::ASSOC_TYPE_ANY,
Expand Down
2 changes: 1 addition & 1 deletion classes/submission/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function deleteById(int $id): int
*
* @return DAOResultFactory<Submission>
*/
public function getExportable($contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null)
public function getExportable(int $contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null)
{
$q = DB::table('submissions', 's')
->leftJoin('publications AS p', 's.current_publication_id', '=', 'p.publication_id')
Expand Down
2 changes: 1 addition & 1 deletion dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

<upgrade minversion="3.1.0.0" maxversion="3.4.9.9">
<migration class="PKP\migration\upgrade\v3_5_0\PreflightCheckMigration" fallback="3.4.9.9" />
<migration class="APP\migration\upgrade\v3_5_0\I8333_AddMissingForeignKeys" />
<migration class="PKP\migration\upgrade\v3_5_0\I9895_AddAppKeyToConfigFile"/>
<migration class="PKP\migration\upgrade\v3_5_0\InstallEmailTemplates"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9197_MigrateAccessKeys"/>
Expand All @@ -121,7 +122,6 @@
<migration class="PKP\migration\upgrade\v3_5_0\I9566_SessionUpgrade"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9809_ReviewCancelDate"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9860_EditorialMastheadNavMenuItem"/>
<migration class="PKP\migration\upgrade\v3_5_0\I8826_AddMissingForeignKeys" />
<migration class="APP\migration\upgrade\v3_5_0\I9937_EditorialTeamToEditorialHistory"/>
<migration class="PKP\migration\upgrade\v3_5_0\I10041_UserGroupsAndUserUserGroupsMastheadValues"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9771_OrcidMigration"/>
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 163 files
3 changes: 2 additions & 1 deletion pages/oai/OAIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace APP\pages\oai;

use APP\core\Application;
use APP\handler\Handler;
use APP\oai\ops\ServerOAI;
use Firebase\JWT\Key;
Expand All @@ -42,7 +43,7 @@ public function index($args, $request)
PluginRegistry::loadCategory('oaiMetadataFormats', true);

$oai = new ServerOAI(new OAIConfig($request->url(null, 'oai'), Config::getVar('oai', 'repository_id')));
if (!$request->getServer() && $request->getRouter()->getRequestedContextPath($request) != 'index') {
if (!$request->getServer() && $request->getRouter()->getRequestedContextPath($request) != Application::SITE_CONTEXT_PATH) {
$dispatcher = $request->getDispatcher();
return $dispatcher->handle404();
}
Expand Down
2 changes: 1 addition & 1 deletion pages/preprints/SectionsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function section($args, $request)
$sectionPath = $args[0] ?? null;
$page = isset($args[1]) && ctype_digit((string) $args[1]) ? (int) $args[1] : 1;
$context = $request->getContext();
$contextId = $context ? $context->getId() : Application::CONTEXT_ID_NONE;
$contextId = $context?->getId() ?? Application::SITE_CONTEXT_ID;

// The page $arg can only contain an integer that's not 1. The first page
// URL does not include page $arg
Expand Down
2 changes: 1 addition & 1 deletion plugins/generic/acron
Submodule acron updated 1 files
+5 −5 AcronPlugin.php

0 comments on commit 8783170

Please sign in to comment.