-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a unique images/icons directory #100
Conversation
There was a problem hiding this comment.
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?
migrations/move_site_icons.php
Outdated
private const NEW_ICON_DIR = 'images/site_icons'; | ||
private const OLD_ICON_DIR = 'images/icons'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
migrations/move_site_icons.php
Outdated
|
||
public function effectively_installed() | ||
{ | ||
return $this->get_filesystem()->exists($this->container->getParameter('core.root_path') . self::NEW_ICON_DIR); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
migrations/move_site_icons.php
Outdated
return ['\phpbb\webpushnotifications\migrations\add_acp_pwa_configs']; | ||
} | ||
|
||
public function update_data(): array |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
migrations/move_site_icons.php
Outdated
$message = $copied ? 'LOG_WEBPUSH_ICON_COPY_SUCCESS' : 'LOG_WEBPUSH_ICON_DIR_SUCCESS'; | ||
$result = [$message => [self::NEW_ICON_DIR]]; | ||
} | ||
catch (filesystem_exception $e) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
'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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
Co-authored-by: rxu <[email protected]>
Co-authored-by: rxu <[email protected]>
No description provided.