Skip to content

Commit

Permalink
Added missing cache variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Nov 23, 2020
1 parent 97451da commit 9a8d404
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion BaseParser.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public abstract function getSubmission(): \Submission;
*/
public abstract function getSection(): \Section;


/**
* Retrieves the public IDs
* @return array Returns array, where the key is the type and value the ID
Expand Down
1 change: 0 additions & 1 deletion Configuration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public function getSubmissionGenre(): \Genre
return $this->_genre;
}


/**
* Retrieves an article iterator
* @return ArticleIterator
Expand Down
4 changes: 2 additions & 2 deletions parsers/aPlusPlus/SectionParser.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public function getSection(): \Section
$sectionNames['en_US'] = end($sectionName);
}

// Tries to find entry in the cache
// Tries to find an entry in the cache
foreach ($sectionNames as $locale => $title) {
if ($this->_section = $cache[$this->getContextId()][$locale][$title] ?? null) {
break;
}
}

if (!$this->_section) {
// Tries to find entry in database
// Tries to find an entry in the database
$sectionDao = \Application::getSectionDAO();
foreach ($sectionNames as $locale => $title) {
if ($this->_section = $sectionDao->getByTitle($title, $this->getContextId(), $locale)) {
Expand Down
2 changes: 2 additions & 0 deletions parsers/jats/IssueParser.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ private function _rollbackIssue(): void
*/
public function getIssue(): \Issue
{
static $cache = [];

if ($this->_issue) {
return $this->_issue;
}
Expand Down
6 changes: 4 additions & 2 deletions parsers/jats/SectionParser.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ private function _rollbackSection(): void
*/
public function getSection(): \Section
{
static $cache = [];

if ($this->_section) {
return $this->_section;
}
Expand All @@ -59,15 +61,15 @@ public function getSection(): \Section
$sectionNames['en_US'] = end($sectionName);
}

// Tries to find entry in the cache
// Tries to find an entry in the cache
foreach ($sectionNames as $locale => $title) {
if ($this->_section = $cache[$this->getContextId()][$locale][$title] ?? null) {
break;
}
}

if (!$this->_section) {
// Tries to find entry in database
// Tries to find an entry in the database
$sectionDao = \Application::getSectionDAO();
foreach ($sectionNames as $locale => $title) {
if ($this->_section = $sectionDao->getByTitle($title, $this->getContextId(), $locale)) {
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<version>
<application>articleImporter</application>
<type>plugins.importexport</type>
<release>1.0.0.0</release>
<date>2020-06-14</date>
<release>1.0.0.1</release>
<date>2020-11-23</date>
</version>

0 comments on commit 9a8d404

Please sign in to comment.