Skip to content

Commit

Permalink
Decrease extraneous fetches
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jun 24, 2024
1 parent bb29c38 commit 5c0e9a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions classes/core/PKPApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\security\Role;
use PKP\site\Version;
use PKP\site\VersionDAO;
use PKP\submission\RepresentationDAOInterface;

Expand Down Expand Up @@ -307,9 +308,7 @@ public function getHttpClient()
$application = Application::get();
$userAgent = $application->getName() . '/';
if (static::isInstalled() && !static::isUpgrading()) {
/** @var \PKP\site\VersionDAO */
$versionDao = DAORegistry::getDAO('VersionDAO');
$currentVersion = $versionDao->getCurrentVersion();
$currentVersion = $application->getCurrentVersion();
$userAgent .= $currentVersion->getVersionString();
} else {
$userAgent .= '?';
Expand Down Expand Up @@ -451,13 +450,10 @@ abstract public function getPluginCategories();

/**
* Return the current version of the application.
*
* @return \PKP\site\Version
*/
public function getCurrentVersion()
public function getCurrentVersion(): Version
{
$currentVersion = $this->getEnabledProducts('core');
assert(count($currentVersion)) == 1;
return $currentVersion[$this->getName()];
}

Expand Down
5 changes: 2 additions & 3 deletions classes/template/PKPTemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ public function smartyLoadStylesheet($params, $smarty)

if (!PKPSessionGuard::isSessionDisable()) {
$versionDao = DAORegistry::getDAO('VersionDAO'); /** @var VersionDAO $versionDao */
$appVersion = $versionDao->getCurrentVersion()->getVersionString();
$appVersion = Application::get()->getCurrentVersion()->getVersionString();
} else {
$appVersion = null;
}
Expand Down Expand Up @@ -2243,8 +2243,7 @@ public function smartyLoadScript($params, $smarty)
}

if (!PKPSessionGuard::isSessionDisable()) {
$versionDao = DAORegistry::getDAO('VersionDAO'); /** @var VersionDAO $versionDao */
$appVersion = $versionDao->getCurrentVersion()->getVersionString();
$appVersion = Application::get()->getCurrentVersion()->getVersionString();
} else {
$appVersion = null;
}
Expand Down

0 comments on commit 5c0e9a2

Please sign in to comment.