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

Fix website measurable type was defining settings and properties for all types #10991

Merged
merged 11 commits into from Dec 12, 2016

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Dec 11, 2016

The settings specified in website measurable type should not apply to any other type by default.

…all types

The settings specified in website measurable type should not apply to any other type by default.
@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review labels Dec 11, 2016
@tsteur tsteur added this to the 3.0.0-rc milestone Dec 11, 2016
if ($this->idMeasurableType !== Type::ID && $this->idMeasurableType !== MobileAppType::ID) {
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

Logically that would be right. But I'm wondering if there would be a better way to switch on/off the settings a measurable type defines. If for example someone wants to create another custom measurable type that should be based on the website settings. Could we maybe check the inheritance of the Type class or something like that and let the MobileType class inherit from the WebsiteType class?

Copy link
Member Author

@tsteur tsteur Dec 11, 2016

Choose a reason for hiding this comment

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

My plan for this was to create classes for all properties and settings similar to https://github.com/piwik/piwik/blob/3.x-dev/plugins/WebsiteMeasurable/Settings/Urls.php and https://github.com/piwik/piwik/blob/3.0.0-rc1/plugins/WebsiteMeasurable/MeasurableSettings.php#L87-L88

So one MeasurableSettings should actually not define anything for another type and each plugin that defines a new type would do eg:

        $this->urls = new Urls($this->idSite);
        $this->addSetting($this->urls);

        $this->excludedUrls = new ExcludedUrls($this->idSite);
        $this->addSetting($this->excludedUrls);
 ...

This is a bit of duplicated code and not best solution but most flexible since often it will be cases that types will want to use only some fields of it.

Probably on top we will need to have something like your suggestion as well for cases where they actually want to have exact same fields, always. I will try to quickly define it like this

Copy link
Member Author

Choose a reason for hiding this comment

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

I will use inheritance for now, but usually inheritance is a bit of a problem and rather not such a good solution but for now it will do

Copy link
Member Author

Choose a reason for hiding this comment

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

done

protected function shouldShowSettingsForType($type)
{
return $type !== Type::ID;
}
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't that be === in both files?

Copy link
Member Author

Choose a reason for hiding this comment

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

could point, I have a look. Think you're right. It still worked because there were only 2 types so didn't notice :)

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@sgiehl
Copy link
Member

sgiehl commented Dec 11, 2016

Guess it's good to merge now 👍

@tsteur
Copy link
Member Author

tsteur commented Dec 12, 2016

It broke the SitesManager.addSite method and won't save anything for any type anymore apart from websites. I will try to find a workaround but am a little stuck. Will see what is possible here without changing too much.

@tsteur
Copy link
Member Author

tsteur commented Dec 12, 2016

Works now. SitesManager.addSite and updateSite can now be used with any type when calling the API and it still works.

Be good to "squash" this PR :)

@mattab mattab merged commit bfb0393 into 3.x-dev Dec 12, 2016
@mattab mattab deleted the website_measurabletype_settings branch December 12, 2016 10:23
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. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants