Skip to content

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

@anonymous-matomo-user

Description

@anonymous-matomo-user

\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 ...

Metadata

Metadata

Assignees

Labels

BugFor errors / faults / flaws / inconsistencies etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions