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
Set a user preference only if user has actually at least view permission to one site #7841
Conversation
… an empty value
* | ||
*/ | ||
|
||
namespace Piwik\Updates; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I placed this update file first in UsersManager plugin since it is needed because of logic there and couldn't really decide whether to place it in that plugin or in core. Placed it in core since it is kinda nice to be able to see all update scripts in one place but I think it rather belongs to UsersManager and we should maybe start putting them into the related plugins if they belong there.
static function getSql() | ||
{ | ||
$optionTable = Common::prefixTable('option'); | ||
$removeEmptyDefaultReportsSql = "delete from $optionTable where option_name like '%defaultReport%' and option_value=''"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "delete from $optionTable
", otherwise will fail on MySQL if there's no table prefix.
Instead of the |
The wrong ones are deleted in the update sql so it should not return an empty value anymore apart from |
Set defaultReport to load user preference only if user has actually at least view permission to one site, so the user preference will not be an empty string.
refs #7839
Background: There is a task that sets the default preference "Report To Load By Default" for each user if none is configured yet. In my Piwik I had many entries in the option table (this is where those values are stored for each user) with an empty value
''
because many users do not have access to any site. Instead we should only set the default preference when there is actually a site.Otherwise following scenario possible I think: User has stored a default preference for
defaultReport =''
because at time, when the task ran, the user did not have access to any site. Now a user gets permission to a site but default preference is still''
meaning because of this check it will return''
as preference and not the default preference: https://github.com/piwik/piwik/blob/2.13.0-rc3/plugins/UsersManager/API.php#L106