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

Don't try to display a custom logo or favicon if they don't exist #10000

Merged
merged 4 commits into from Apr 11, 2016

Conversation

ksubileau
Copy link
Contributor

A possible fix for #9966

@quba
Copy link
Contributor

quba commented Apr 5, 2016

Gratz! Issue/pr nb #10000 :)

@@ -163,6 +163,16 @@ protected static function rewritePath($path)
return SettingsPiwik::rewriteMiscUserPathWithInstanceId($path);
}

public static function hasUserLogo()
{
return file_exists(Filesystem::getPathToPiwikRoot() . '/' . CustomLogo::getPathUserLogo());
Copy link
Member

Choose a reason for hiding this comment

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

BTW: Here you could use PIWIK_INCLUDE_PATH . CustomLogo::getPathUserLogo() and same below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the code from the existing hasSvgLogo and getPathToLogo methods for consistency :). Is there any difference between the static method and the constant? Should I still use the constant?

Copy link
Member

Choose a reason for hiding this comment

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

good point, I didn't notice that. Consistency is always good. We usually always use PIWIK_INCLUDE_PATH but not sure why Filesystem::getPathToPiwikRoot() was used there is there's no difference and the constant should be better. I'm ok with Filesystem::getPathToPiwikRoot() in this case. To remove the duplicated code though maybe there could be a method like

private function getRootPath()
{
    return Filesystem::getPathToPiwikRoot() . '/';
}
// or 
private function getAbsolutePath($reference)
{
    return Filesystem::getPathToPiwikRoot() . '/' . $reference;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you prefer, we can also replace all calls to this method in this file by the constant.
If we add a new method getAbsolutePath, I think it should be in the Filesystem class, isn't it ?

Copy link
Member

Choose a reason for hiding this comment

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

Somehow I would prefer not to have it in Filesystem but would be also ok there. Having a look at this again in the code there is often file_exists($pathToPiwikRoot . '/' . $customLogo) etc, finding several file_exists. The code seems quite confusing in there in general and needs to be refactored at some point. Maybe there could me instead a method

private function logoExists($reference)
{
    return file_exists(Filesystem::getPathToPiwikRoot() . '/' . $reference);
}

Of course this could be as well in Filesystem but might be as well fine in CustomLogo for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 637b839 ;)

@tsteur
Copy link
Member

tsteur commented Apr 5, 2016

I tested it and works great 👍 Just made two really minor comments but after those changes we can merge. Thank you for that and for getting this done so quick 👍

@tsteur tsteur added this to the 2.16.2 milestone Apr 5, 2016
@tsteur tsteur added the Needs Review PRs that need a code review label Apr 5, 2016
@tsteur
Copy link
Member

tsteur commented Apr 11, 2016

Awesome 👍 👍 Thanks for this. Merging now

@tsteur tsteur merged commit 120a7f7 into matomo-org:master Apr 11, 2016
@ksubileau ksubileau deleted the 9966 branch April 16, 2016 09:49
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Aug 2, 2016
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. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants