Skip to content

Commit

Permalink
Merge pull request pkp#1203 from bozana/master
Browse files Browse the repository at this point in the history
pkp/pkp-lib#1924 fix file names upgrade and supp file array
  • Loading branch information
bozana authored Jan 23, 2017
2 parents 482c129 + df047b5 commit 140c1fb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions classes/install/Upgrade.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,17 @@ function migrateFiles($upgrade, $params) {
$site = $siteDao->getSite();
$adminEmail = $site->getLocalizedContactEmail();

// get file names form OJS 2.4.x table article_files i.e.
// from the temporary table article_files_migration
$ojs2FileNames = array();
$result = $submissionFileDao->retrieve('SELECT file_id, revision, file_name FROM article_files_migration');
while (!$result->EOF) {
$row = $result->GetRowAssoc(false);
$ojs2FileNames[$row['file_id']][$row['revision']] = $row['file_name'];
$result->MoveNext();
}
$result->Close();

import('lib.pkp.classes.file.SubmissionFileManager');

$contexts = $journalDao->getAll();
Expand All @@ -870,11 +881,7 @@ function migrateFiles($upgrade, $params) {
foreach ($submissionFiles as $submissionFile) {
$generatedFilename = $submissionFile->getServerFileName();
$basePath = $submissionFileManager->getBasePath() . '/';
$globPattern = $submissionFile->getSubmissionId() . '-' .
$submissionFile->getFileId() . '-' .
$submissionFile->getRevision() . '-' .
'??' .
'.' . strtolower_codesafe($submissionFile->getExtension());
$globPattern = $ojs2FileNames[$submissionFile->getFileId()][$submissionFile->getRevision()];

$matchedResults = array_merge(
glob($basePath . '*/*/' . $globPattern),
Expand Down Expand Up @@ -1250,7 +1257,7 @@ function convertSupplementaryFiles() {

// Set genres for files
$submissionFiles = $submissionFileDao->getAllRevisions($row['file_id']);
foreach ($submissionFiles as $submissionFile) {
foreach ((array) $submissionFiles as $submissionFile) {
$submissionFile->setGenreId($genre->getId());
$submissionFile->setUploaderUserId($creatorUserId);
$submissionFile->setUserGroupId($managerUserGroup->getId());
Expand All @@ -1260,7 +1267,7 @@ function convertSupplementaryFiles() {

// Reload the files now that they're cast; set metadata
$submissionFiles = $submissionFileDao->getAllRevisions($row['file_id']);
foreach ($submissionFiles as $submissionFile) {
foreach ((array) $submissionFiles as $submissionFile) {
$suppFileSettingsResult = $submissionFileDao->retrieve('SELECT * FROM article_supp_file_settings WHERE supp_id = ? AND setting_value IS NOT NULL', array($row['supp_id']));
$extraSettings = $extraGalleySettings = array();
while (!$suppFileSettingsResult->EOF) {
Expand Down

0 comments on commit 140c1fb

Please sign in to comment.