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

Fixes #7647 Variable overwriting itself #7666

Merged
merged 2 commits into from Apr 15, 2015
Merged

Fixes #7647 Variable overwriting itself #7666

merged 2 commits into from Apr 15, 2015

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Apr 12, 2015

Fixes #7647

The original issue also mentioned:

Also I think getAllUsersPreferences does not return default values so a key might be not set.

Not able to reproduce but just in case I have added some code to handle that case.

@mnapoli mnapoli added Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. labels Apr 12, 2015
@mnapoli mnapoli added this to the Piwik 2.13.0 milestone Apr 12, 2015

foreach ($allUsersPreferences as $userLogin => $userPreferences) {

if (!isset($userPreferences[APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE])) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be allowed for this to be empty, see UserPreferences::getDefaultPeriod which defaults it to the [General] default_period value. If that config value is set to 'range', then this range archiving will be executed for every user which may not be desired...

CC @mattab What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right I think I see what you mean. This api is depressing me, there's 0 encapsulation and we've got to care about the internal details everywhere (got the same kind of problems in another PR)… Thing is changing it is sometimes hard if the method is used/tagged with api as it could break BC. 😞

Copy link
Member

Choose a reason for hiding this comment

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

If that config value is set to 'range', then this range archiving will be executed for every user which may not be desired...

FYI reading the config setting in global.ini it says:

; Possible values: day, week, month, year.
default_period = day

so range is not supported for this config setting.

Copy link
Member

Choose a reason for hiding this comment

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

On further examination, my comment isn't accurate, if the preference is empty, it's the actual date to use that's empty, not the period, which means the rest of the code wouldn't work.

Will merge momentarily.

diosmosis added a commit that referenced this pull request Apr 15, 2015
Fixes #7647 In CronArchive:: loadCustomDateRangeToPreProcess, fix variable in for loop overwriting itself, and do not execute archiving of custom date ranges for user if the PREFERENCE_DEFAULT_REPORT_DATE preference is for some reason not set.
@diosmosis diosmosis merged commit db00b7d into master Apr 15, 2015
@diosmosis diosmosis deleted the fix/7647 branch April 15, 2015 23:43
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. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants