Skip to content

Commit

Permalink
pkp/pkp-lib#5122 Update naming pattern when returning an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr authored and ajnyga committed Nov 17, 2019
1 parent 017084b commit 53ccc5b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions classes/components/forms/site/SiteConfigForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct($action, $locales, $site) {
$this->successMessage = __('admin.settings.config.success');
$this->locales = $locales;

$result = \Services::get('context')->getMany(['isEnabled' => true]);
$contextsIterator = \Services::get('context')->getMany(['isEnabled' => true]);

$this->addField(new FieldText('title', [
'label' => __('admin.settings.siteTitle'),
Expand All @@ -46,9 +46,9 @@ public function __construct($action, $locales, $site) {
'value' => $site->getData('title'),
]));

if (count($result)) {
if (count($contextsIterator)) {
$options = [['value' => '', 'label' => '']];
foreach ($result as $context) {
foreach ($contextsIterator as $context) {
$options[] = [
'value' => $context->getId(),
'label' => $context->getLocalizedData('name'),
Expand Down
4 changes: 2 additions & 2 deletions classes/journal/SectionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,12 @@ function getEditorSections($journalId) {
*/
function getByIssueId($issueId) {
$issue = Services::get('issue')->get($issueId);
$result = Services::get('submission')->getMany([
$submissionsIterator = Services::get('submission')->getMany([
'contextId' => $issue->getJournalId(),
'issueIds' => $issueId,
]);
$sectionIds = [];
foreach ($result as $submission) {
foreach ($submissionsIterator as $submission) {
$sectionIds[] = $submission->getCurrentPublication()->getData('sectionId');
}
$sectionIds = array_unique($sectionIds);
Expand Down
4 changes: 2 additions & 2 deletions classes/plugins/PubIdPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ function clearIssueObjectsPubIds($issue) {
$submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
import('lib.pkp.classes.submission.SubmissionFile'); // SUBMISSION_FILE_... constants

$result = Services::get('submission')->getMany([
$submissionsIterator = Services::get('submission')->getMany([
'contextId' => $issue->getJournalId(),
'issueIds' => $issue->getId(),
'count' => 5000, // large upper limit
]);
foreach ($result as $submission) {
foreach ($submissionsIterator as $submission) {
if ($submissionPubIdEnabled) { // Does this option have to be enabled here for?
$submissionDao->deletePubId($submission->getId(), $pubIdType);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/search/ArticleSearchIndex.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ public function rebuildIndex($log = false, $journal = null, $switches = array())

if ($log) echo __('search.cli.rebuildIndex.indexing', array('journalName' => $journal->getLocalizedName())) . ' ... ';

$result = Services::get('submission')->getMany(['contextId' => $journal->getId()]);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany(['contextId' => $journal->getId()]);
foreach ($submissionsIterator as $submission) {
if ($submission->getSubmissionProgress() == 0) { // Not incomplete
$this->submissionMetadataChanged($submission);
$this->submissionFilesChanged($submission);
Expand Down
4 changes: 2 additions & 2 deletions classes/services/IssueService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ public function getProperties($issue, $props, $args = null) {
break;
case 'articles':
$values[$prop] = array();
$result = Services::get('submission')->getMany([
$submissionsIterator = Services::get('submission')->getMany([
'contextId' => $issue->getJournalId(),
'issueIds' => $issue->getId(),
'count' => 1000, // large upper limit
]);
foreach ($result as $submission) {
foreach ($submissionsIterator as $submission) {
$values[$prop][] = \Services::get('submission')->getSummaryProperties($submission, $args);
}
break;
Expand Down
4 changes: 2 additions & 2 deletions classes/services/PublicationService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function publishPublication($hookName, $args) {
public function deletePublicationBefore($hookName, $args) {
$publication = $args[0];

$result = Services::get('galley')->getMany(['publicationIds' => $publication->getId()]);
foreach ($result as $galley) {
$galleysIterator = Services::get('galley')->getMany(['publicationIds' => $publication->getId()]);
foreach ($galleysIterator as $galley) {
Services::get('galley')->delete($galley);
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/SubmissionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function newDataObject() {
* @copydoc SchemaDAO::deleteById
*/
function deleteById($submissionId) {
$result = Services::get('publication')->getMany(['submissionIds' => $submissionId]);
$publicationsIterator = Services::get('publication')->getMany(['submissionIds' => $submissionId]);

foreach ($result as $publication) {
foreach ($publicationsIterator as $publication) {
$galleys = DAORegistry::getDAO('ArticleGalleyDAO')->getByPublicationId($publication->getId())->toArray();
foreach ($galleys as $galley) {
DAORegistry::getDAO('ArticleGalleyDAO')->deleteById($galley->getId());
Expand Down
6 changes: 3 additions & 3 deletions pages/article/ArticleHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ function initialize($request, $args = array()) {
$urlPath = empty($args) ? 0 : array_shift($args);

// Look for a publication with a publisher-id that matches the url path
$result = Services::get('publication')->getMany([
$publicationsIterator = Services::get('publication')->getMany([
'contextIds' => $request->getContext()->getId(),
'publisherIds' => $urlPath,
]);
$publicationWithMatchingUrl = null;
if (count($result)) {
$publicationWithMatchingUrl = $result->current();
if (count($publicationsIterator)) {
$publicationWithMatchingUrl = $publicationsIterator->current();
$submissionId = $publicationWithMatchingUrl->getData('submissionId');
} elseif (ctype_digit($urlPath)) {
$submissionId = $urlPath;
Expand Down
4 changes: 2 additions & 2 deletions pages/sitemap/SitemapHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ function _createContextSitemap($request) {
while ($issue = $publishedIssues->next()) {
$root->appendChild($this->_createUrlTree($doc, $request->url($journal->getPath(), 'issue', 'view', $issue->getId())));
// Articles for issue
$result = Services::get('submission')->getMany([
$submissionsIterator = Services::get('submission')->getMany([
'issueIds' => $issue->getId(),
]);
foreach($result as $submission) {
foreach($submissionsIterator as $submission) {
// Abstract
$root->appendChild($this->_createUrlTree($doc, $request->url($journal->getPath(), 'article', 'view', array($submission->getBestId()))));
// Galley files
Expand Down

0 comments on commit 53ccc5b

Please sign in to comment.