Skip to content

Commit

Permalink
Merge pull request #719 from NateWr/i5122_iterator
Browse files Browse the repository at this point in the history
 pkp/pkp-lib#5122 Update naming pattern when returning iterators
  • Loading branch information
asmecher authored Oct 24, 2019
2 parents 95b18e7 + 9c2cb26 commit 6199d14
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions classes/press/SeriesDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function deleteById($seriesId, $contextId = null) {
$subEditorsDao->deleteBySectionId($seriesId, $contextId);

// Remove monographs from this series
$result = Services::get('submission')->getMany(['seriesIds' => $seriesId, 'count' => 1000]);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany(['seriesIds' => $seriesId, 'count' => 1000]);
foreach ($submissionsIterator as $submission) {
foreach ((array) $submission->getData('publications') as $publication) {
Services::get('publication')->edit($publication, ['seriesId' => 0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function insertTombstonesByPublicationFormats($publicationFormats, $press) {
* @param $press
*/
function insertTombstonesByPress($press) {
$result = Services::get('submission')->getMany(['contextId' => $press->getId(), 'status' => STATUS_PUBLISHED, 'count' => 2000]);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany(['contextId' => $press->getId(), 'status' => STATUS_PUBLISHED, 'count' => 2000]);
foreach ($submissionsIterator as $submission) {
foreach ($submission->getData('publications') as $publication) {
$this->insertTombstonesByPublicationFormats($publication->getData('publicationFormats'), $press);
}
Expand All @@ -104,8 +104,8 @@ function deleteTombstonesByPublicationFormats($publicationFormats) {
* @param $pressId int
*/
function deleteTombstonesByPressId($pressId) {
$result = Services::get('submission')->getMany(['contextId' => $pressId, 'status' => STATUS_PUBLISHED, 'count' => 2000]);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany(['contextId' => $pressId, 'status' => STATUS_PUBLISHED, 'count' => 2000]);
foreach ($submissionsIterator as $submission) {
foreach ($submission->getData('publications') as $publication) {
$this->deleteTombstonesByPublicationFormats($publication->getData('publicationFormats'));
}
Expand Down
8 changes: 4 additions & 4 deletions classes/services/PublicationService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ public function versionPublication($hookName, $args) {
}

// Chapters (and all associated objects)
$oldAuthorsResult = Services::get('author')->getMany(['publicationIds' => $oldPublication->getId(), 'count' => 1000]);
$newAuthorsResult = Services::get('author')->getMany(['publicationIds' => $newPublication->getId(), 'count' => 1000]);
$oldAuthorsIterator = Services::get('author')->getMany(['publicationIds' => $oldPublication->getId(), 'count' => 1000]);
$newAuthorsIterator = Services::get('author')->getMany(['publicationIds' => $newPublication->getId(), 'count' => 1000]);
$result = DAORegistry::getDAO('ChapterDAO')->getByPublicationId($oldPublication->getId());
while (!$result->eof()) {
$oldChapter = $result->next();
Expand All @@ -296,8 +296,8 @@ public function versionPublication($hookName, $args) {
// old one. We then map the old chapter author associations to the new
// authors.
$oldChapterAuthors = DAORegistry::getDAO('ChapterAuthorDAO')->getAuthors($oldPublication->getId(), $oldChapter->getId())->toArray();
foreach ($newAuthorsResult as $newAuthor) {
foreach ($oldAuthorsResult as $oldAuthor) {
foreach ($newAuthorsIterator as $newAuthor) {
foreach ($oldAuthorsIterator as $oldAuthor) {
if ($newAuthor->getData('seq') === $oldAuthor->getData('seq')) {
foreach ($oldChapterAuthors as $oldChapterAuthor) {
if ($oldChapterAuthor->getId() === $oldAuthor->getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ function itemAutocomplete($args, $request) {
$args['searchPhrase'] = $name;
}

$result = Services::get('submission')->getMany($args);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany($args);
foreach ($submissionsIterator as $submission) {
$matches[] = array('label' => $submission->getLocalizedTitle(), 'value' => $submission->getId() . ':' . SPOTLIGHT_TYPE_BOOK);
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/users/chapter/form/ChapterForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ function fetch($request, $template = null, $display = false) {
];
}
}
$result = Services::get('author')->getMany(['publicationIds' => $this->getPublication()->getId(), 'count' => 1000]);
foreach ($result as $author) {
$authorsIterator = Services::get('author')->getMany(['publicationIds' => $this->getPublication()->getId(), 'count' => 1000]);
foreach ($authorsIterator as $author) {
$isIncluded = false;
foreach ($chapterAuthorOptions as $chapterAuthorOption) {
if ($chapterAuthorOption['id'] === $author->getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ function fetch($args, $request) {
]
);
$params = array_merge($selectNewEntryListPanel->getParams, ['contextId' => $request->getContext()->getId()]);
$result = \Services::get('submission')->getMany($params);
$submissionsIterator = \Services::get('submission')->getMany($params);
$items = [];
foreach ($result as $submission) {
foreach ($submissionsIterator as $submission) {
$items[] = \Services::get('submission')->getBackendListProperties($submission, ['request' => $request]);
}
$selectNewEntryListPanel->set([
Expand Down
12 changes: 6 additions & 6 deletions pages/catalog/CatalogHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ public function page($args, $request, $isFirstPage = false) {
'offset' => $offset,
'status' => STATUS_PUBLISHED,
);
$submissionsResult = $submissionService->getMany($params);
$submissionsIterator = $submissionService->getMany($params);
$total = $submissionService->getMax($params);

$featureDao = DAORegistry::getDAO('FeatureDAO');
$featuredMonographIds = $featureDao->getSequencesByAssoc(ASSOC_TYPE_PRESS, $context->getId());

$this->_setupPaginationTemplate($request, count($submissionsResult), $page, $count, $offset, $total);
$this->_setupPaginationTemplate($request, count($submissionsIterator), $page, $count, $offset, $total);

$templateMgr->assign(array(
'publishedSubmissions' => iterator_to_array($submissionsResult),
'publishedSubmissions' => iterator_to_array($submissionsIterator),
'featuredMonographIds' => $featuredMonographIds,
));

Expand Down Expand Up @@ -155,7 +155,7 @@ function series($args, $request) {
'offset' => $offset,
'status' => STATUS_PUBLISHED,
);
$submissionsResult = $submissionService->getMany($params);
$submissionsIterator = $submissionService->getMany($params);
$total = $submissionService->getMax($context->getId(), $params);

$featureDao = DAORegistry::getDAO('FeatureDAO');
Expand All @@ -168,11 +168,11 @@ function series($args, $request) {
$newReleases = $newReleaseDao->getMonographsByAssoc(ASSOC_TYPE_SERIES, $series->getId());
}

$this->_setupPaginationTemplate($request, count($submissionsResult), $page, $count, $offset, $total);
$this->_setupPaginationTemplate($request, count($submissionsIterator), $page, $count, $offset, $total);

$templateMgr->assign(array(
'series' => $series,
'publishedSubmissions' => iterator_to_array($submissionsResult),
'publishedSubmissions' => iterator_to_array($submissionsIterator),
'featuredMonographIds' => $featuredMonographIds,
'newReleasesMonographs' => $newReleases,
));
Expand Down
4 changes: 2 additions & 2 deletions pages/manageCatalog/ManageCatalogHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ function index($args, $request) {
'count' => $catalogList->count,
'contextId' => $context->getId(),
]);
$result = $submissionService->getMany($params);
$submissionsIterator = $submissionService->getMany($params);
$items = [];
foreach ($result as $submission) {
foreach ($submissionsIterator as $submission) {
$items[] = $submissionService->getBackendListProperties($submission, ['request' => $request]);
}
$catalogList->set([
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 @@ -30,8 +30,8 @@ function _createContextSitemap($request) {
// Catalog
$root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog')));

$result = Services::get('submission')->getMany(['status' => STATUS_PUBLISHED, 'contextId' => $pressId, 'count' => 1000]);
foreach ($result as $submission) {
$submissionsIterator = Services::get('submission')->getMany(['status' => STATUS_PUBLISHED, 'contextId' => $pressId, 'count' => 1000]);
foreach ($submissionsIterator as $submission) {
// Book
$root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'view', array($submission->getBestId()))));
// Files
Expand Down

0 comments on commit 6199d14

Please sign in to comment.