Skip to content

Use a unique images/icons directory#100

Merged
iMattPro merged 11 commits into
phpbb-extensions:mainfrom
iMattPro:move-icons
Dec 13, 2024
Merged

Use a unique images/icons directory#100
iMattPro merged 11 commits into
phpbb-extensions:mainfrom
iMattPro:move-icons

Conversation

@iMattPro

@iMattPro iMattPro commented Dec 9, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@rxu rxu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, looking at the PR now I think we're performing some risky and unreliable migration actions for a little advantage :) Maybe leave it as is now?

Comment on lines +19 to +20
private const NEW_ICON_DIR = 'images/site_icons';
private const OLD_ICON_DIR = 'images/icons';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just add OLD_ICON_DIR to the ext class and then use both it and PWA_ICON_DIR here statically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the migration I wanted to keep as much as possible self contained. OLD_ICON_DIR is only ever used here so there's no real reason to put it into the ext file. I thought about using PWA_ICON_DIR here for NEW_ICON_DIR, but then the migration would rely on our ext file which I want to avoid. Also, setting a constant with another constant seems wonky too const NEW_ICON_DIR = PWA_ICON_DIR


public function effectively_installed()
{
return $this->get_filesystem()->exists($this->container->getParameter('core.root_path') . self::NEW_ICON_DIR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also if pwa_icon_small && pwa_icon_large config values aren't empty, otherwise there's nothing to migrate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to create the new site_icons directory regardless of if there is an existing config value

return ['\phpbb\webpushnotifications\migrations\add_acp_pwa_configs'];
}

public function update_data(): array

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add revert_data()? Basically removing the icons dir.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we leave the directory behind. It could be used for other images, like favicons and additional touch icons. We never want to delete any files outside of the extension.

$message = $copied ? 'LOG_WEBPUSH_ICON_COPY_SUCCESS' : 'LOG_WEBPUSH_ICON_DIR_SUCCESS';
$result = [$message => [self::NEW_ICON_DIR]];
}
catch (filesystem_exception $e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how try/catch will work within migration. Feels like it'll throw uncaught exception on failure which will stop extension installation and break things on user end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why there's the catch. It'll gracefully catch any of the exceptions the filesystem throws and log the event. Doesn't stop installation.

@iMattPro

iMattPro commented Dec 10, 2024

Copy link
Copy Markdown
Contributor Author

To be honest, looking at the PR now I think we're performing some risky and unreliable migration actions for a little advantage :) Maybe leave it as is now?

tom-cruise-wtf-tom-cruise

Comment thread language/en/webpushnotifications_common_acp.php Outdated
'LOG_WEBPUSH_SUBSCRIPTION_REMOVED' => '<strong>Удалена подписка на браузерные push—уведомления:</strong>» %s',
'LOG_WEBPUSH_MESSAGE_FAIL' => '<strong>Не удалось отправить браузерное push—уведомление:</strong><br>» %s',
'LOG_WEBPUSH_SUBSCRIPTION_REMOVED' => '<strong>Удалена подписка на браузерные push—уведомления:</strong><br>» %s',
'LOG_WEBPUSH_ICON_DIR_FAIL' => '<strong>Webpush Notifications could not migrate the following item in phpBB’s images directory:</strong><br>» %1$s » %2$s',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rxu can you help with these?

@rxu rxu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

Comment thread language/ru/info_acp_webpushnotifications.php Outdated
Comment thread language/ru/webpushnotifications_common_acp.php Outdated
iMattPro and others added 2 commits December 12, 2024 18:02
@iMattPro
iMattPro merged commit 2a8b81b into phpbb-extensions:main Dec 13, 2024
@iMattPro
iMattPro deleted the move-icons branch December 13, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants