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

not checked type of return value in \Piwik\Plugin\Manager::deactivateThemeIfTheme #4961

Closed
anonymous-matomo-user opened this issue Apr 7, 2014 · 3 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.

Comments

@anonymous-matomo-user
Copy link

\Piwik\Plugin\Manager::getThemeEnabled is returning either an object or false, but \Piwik\Plugin\Manager::deactivateThemeIfTheme does not check for false, so there is a condition missing, if there is not theme available the default one should be activated, anyway any error should be avoided

    private function deactivateThemeIfTheme($pluginName)
    {
        // Only one theme enabled at a time
        $themeEnabled = $this->getThemeEnabled();
        if($themeEnabled !== false) {
            if ($themeEnabled->getPluginName() != self::DEFAULT_THEME) {
                $themeAlreadyEnabled = $themeEnabled->getPluginName();

                $plugin = $this->loadPlugin($pluginName);
                if ($plugin->isTheme()) {
                    $this->deactivatePlugin($themeAlreadyEnabled);
                }
            }
        }
    }

PS: I found that bug while upgrading my TYPO3 Integration plugin for TYPO3 ...

@anonymous-matomo-user
Copy link
Author

ok, just found out, that this is not the only place where the check is ommitted ..., so the default theme should be applied here


private function deactivateThemeIfTheme($pluginName)
    {
        // Only one theme enabled at a time
        $themeEnabled = $this->getThemeEnabled();
        if($themeEnabled === false) {
            $this->loadPlugin(self::DEFAULT_THEME);
            $this->activatePlugin(self::DEFAULT_THEME);
        } else {
            if ($themeEnabled->getPluginName() != self::DEFAULT_THEME) {
                $themeAlreadyEnabled = $themeEnabled->getPluginName();

                $plugin = $this->loadPlugin($pluginName);
                if ($plugin->isTheme()) {
                    $this->deactivatePlugin($themeAlreadyEnabled);
                }
            }
        }
    }

@mattab
Copy link
Member

mattab commented Apr 8, 2014

In fe88778: Fixes #4961 Thanks for the report & patch!

@mattab
Copy link
Member

mattab commented Apr 8, 2014

In e0041ed: Refs #4961 Another fix. Let me know if you still see notices/warnings related to this

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants