Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c5ffd5f

Browse files
committed
Catch error on minisite migration
1 parent acd5cd3 commit c5ffd5f

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

core/src/plugins/action.share/class.LegacyPubliclet.php

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -342,31 +342,34 @@ public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightM
342342
rename($legacyLinkFile, $legacyLinkFile.".migrated");
343343
if(isSet($share["minisite"])){
344344
print("\n--Migrate legacy minisite to new minisite?");
345-
$sharedRepoId = $publiclet["REPOSITORY"];
346-
$sharedRepo = ConfService::getRepositoryById($sharedRepoId);
347-
if($sharedRepo == null){
348-
print("\n--ERROR: Cannot find repository with id ".$sharedRepoId);
349-
continue;
350-
}
351-
$shareLink = new ShareLink($shareStore, $publiclet);
352-
$user = $shareLink->getUniqueUser();
353-
if(AuthService::userExists($user)){
354-
$userObject = ConfService::getConfStorageImpl()->createUserObject($user);
355-
$userObject->setHidden(true);
356-
print("\n--Should set existing user $user as hidden");
345+
try{
346+
$sharedRepoId = $publiclet["REPOSITORY"];
347+
$sharedRepo = ConfService::getRepositoryById($sharedRepoId);
348+
if($sharedRepo == null){
349+
print("\n--ERROR: Cannot find repository with id ".$sharedRepoId);
350+
continue;
351+
}
352+
$shareLink = new ShareLink($shareStore, $publiclet);
353+
$user = $shareLink->getUniqueUser();
354+
if(AuthService::userExists($user)){
355+
$userObject = ConfService::getConfStorageImpl()->createUserObject($user);
356+
$userObject->setHidden(true);
357+
print("\n--Should set existing user $user as hidden");
358+
if(!$dryRun){
359+
$userObject->save();
360+
}
361+
}
362+
$shareLink->parseHttpVars(["custom_handle" => $element]);
363+
$shareLink->setParentRepositoryId($sharedRepo->getParentId());
364+
print("\n--Creating the following share object");
365+
print_r($shareLink->getJsonData($shareCenter->getPublicAccessManager(), ConfService::getMessages()));
357366
if(!$dryRun){
358-
$userObject->save();
367+
$shareLink->save();
359368
}
369+
$meta["ajxp_shared"] = ["shares" => [$element => ["type" => "minisite"], $sharedRepoId => ["type" => "repository"]]];
370+
}catch(Exception $e){
371+
print("\n-- Error ".$e->getMessage());
360372
}
361-
$shareLink->parseHttpVars(["custom_handle" => $element]);
362-
$shareLink->setParentRepositoryId($sharedRepo->getParentId());
363-
print("\n--Creating the following share object");
364-
print_r($shareLink->getJsonData($shareCenter->getPublicAccessManager(), ConfService::getMessages()));
365-
if(!$dryRun){
366-
$shareLink->save();
367-
}
368-
$meta["ajxp_shared"] = ["shares" => [$element => ["type" => "minisite"], $sharedRepoId => ["type" => "repository"]]];
369-
370373

371374
}else{
372375
print("\n--Should migrate legacy link to new minisite with ContentFilter");

0 commit comments

Comments
 (0)