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

New init function for plugins, supports errors reporting #659

Merged
merged 1 commit into from
Oct 17, 2016

Conversation

ArthurHoaro
Copy link
Member

All plugins can optionally add an init function named pluginname_init() which is called when the plugin is loaded.

This function is aware of the config, and can return initialization errors, which are displayed in the header template.

Note that the previous error system hack no longer work.

All plugins can optionally add an init function named `pluginname_init()` which is called when the plugin is loaded.

This function is aware of the config, and can return initialization errors, which are displayed in the header template.

Note that the previous error system hack no longer work.
@ArthurHoaro ArthurHoaro added plugin bells and whistles in review labels Oct 14, 2016
@ArthurHoaro ArthurHoaro added this to the 0.8.1 milestone Oct 14, 2016
@ArthurHoaro ArthurHoaro self-assigned this Oct 14, 2016
@ArthurHoaro ArthurHoaro mentioned this pull request Oct 14, 2016
@virtualtam virtualtam mentioned this pull request Oct 16, 2016
20 tasks
{
$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
if (empty($riyUrl)) {
$error = 'Readityourself plugin error: '.
Copy link
Member

Choose a reason for hiding this comment

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

no need to assign a variable, an error array can be returned directly:

if (empty($riyUrl)) {
    return array('Error message');
}

Copy link
Member Author

@ArthurHoaro ArthurHoaro Oct 16, 2016

Choose a reason for hiding this comment

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

You're right, but when I'm dealing with a long string, I prefer to affect it before doing anything with it. I can change this if you think that's better.

Copy link
Member

Choose a reason for hiding this comment

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

not a big deal, this could even come handy for more complex plugins that require checking several resources/config entries

{
$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
if (empty($wallabagUrl)) {
$error = 'Wallabag plugin error: '.
Copy link
Member

Choose a reason for hiding this comment

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

no need to assign a variable, an error array can be returned directly:

if (empty($wallabagUrl)) {
    return array('Error message');
}

{
$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
if (empty($riyUrl)) {
$error = 'Readityourself plugin error: '.
Copy link
Member

Choose a reason for hiding this comment

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

not a big deal, this could even come handy for more complex plugins that require checking several resources/config entries

@ArthurHoaro ArthurHoaro merged commit 06eec9b into shaarli:master Oct 17, 2016
@ArthurHoaro ArthurHoaro deleted the plugin-errors branch October 17, 2016 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin bells and whistles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants