Skip to content
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

Merged
merged 11 commits into from
Dec 13, 2024

Conversation

iMattPro
Copy link
Contributor

@iMattPro iMattPro commented Dec 9, 2024

No description provided.

Copy link
Contributor

@rxu rxu left a 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?

Comment on lines 19 to 20
private const NEW_ICON_DIR = 'images/site_icons';
private const OLD_ICON_DIR = 'images/icons';
Copy link
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
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
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
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
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
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
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
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
Copy link
Contributor Author

iMattPro commented Dec 10, 2024

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

'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
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?

Copy link
Contributor

@rxu rxu left a comment

Choose a reason for hiding this comment

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

Sure, done.

language/ru/info_acp_webpushnotifications.php Outdated Show resolved Hide resolved
language/ru/webpushnotifications_common_acp.php Outdated Show resolved Hide resolved
@iMattPro iMattPro merged commit 2a8b81b into phpbb-extensions:main Dec 13, 2024
32 checks passed
@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