Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Command/Db/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected function runCommands(): int {

$this->printComment('Step 2. Tidy records before rebuilding the schema');
$this->fixNullish();
$this->migrateShareLabels();

$this->printComment('Step 3. Create or update tables to current shema');
$this->createOrUpdateSchema();
Expand Down Expand Up @@ -101,6 +102,12 @@ private function fixNullish(): void {
$this->printInfo($messages, ' ');
}

private function migrateShareLabels(): void {
$this->printComment(' - migrate share labels to displayname for public shares');
$messages = $this->tableManager->migrateShareLabels();
$this->printInfo($messages, ' ');
}

/**
* Create index for $table
*/
Expand Down
27 changes: 16 additions & 11 deletions lib/Db/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
* @method ?int getAnonymizedVotes()
* @method int getDeleted()
* @method void setDeleted(int $value)
* @method ?string getLabel()
* @method void setLabel(?string $value)
*/
class Share extends EntityWithUser implements JsonSerializable {
/** @var string */
Expand Down Expand Up @@ -204,25 +202,32 @@ public function setPublicPollEmail(string $value): void {
}

/**
* Share label for public shares, falls back to username until migrated
* TODO: remove fallback after migration was introduced
* Share label for public shares, now stored as displayName
* TODO: remove after migration was introduced
*/
public function setLabel(string $label): void {
$this->setDisplayName($label);
$this->label = $label;
}

/**
* Share label for public shares
* TODO: remove after migrating labels to displayName
*/
public function getLabel(): string {
if ($this->getType() === self::TYPE_PUBLIC && $this->label) {
return $this->label;
}
return $this->displayName ?? '';
// In case of public poll use label as fallback for displayName
return $this->displayName ?? $this->label ?? '';
}

/**
* Sharee's displayName. In case of public poll label is used instead
* TODO: remove public poll chaeck after migration to label
* TODO: remove public poll check after migration labels to displayName
*/
public function getDisplayName(): string {
if ($this->getType() === self::TYPE_PUBLIC) {
return '';
return $this->getLabel();
}
return (string)$this->displayName;
return $this->displayName ?? '';
}

public function getTimeZoneName(): string {
Expand Down
Loading