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

$userPreferences->getDefaultReport() gives Empty String when not set. #7839

Closed
pouyana opened this issue May 5, 2015 · 5 comments
Closed
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@pouyana
Copy link

pouyana commented May 5, 2015

A User with view Access, can not visit her/his settings (citing no IdSite was set). After testing I found out that in UsersManager->UserSettings() the $userPreferences->getDefaultReport() gives "", an empty string. Going to UserPrefrence class, you see this:

    public function getDefaultReport()
    {
        $defaultReport = $this->api->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT);
        if (!is_numeric($defaultReport)) {
            return $defaultReport;
        }
        if ($defaultReport && Piwik::isUserHasViewAccess($defaultReport)) {
            return $defaultReport;
        }
        return false;
    }

So having empty string leads to sending empty string to view controller, I changed the !is:numeric to is_numeric and everything works.

So is there any other solution than here working or should a default-report be set for a newly created user?

@tsteur
Copy link
Member

tsteur commented May 5, 2015

You should not change !is_numeric to is_numeric. It should not lead to any security issues I think but when a user logs in and this functions returns a site the user doesn't have access to, the user might not be able to do anything.

Can you execute the following SQL query and post the result here?

select * from piwik_option where option_name like 'YOURUSERNAME_defaultReport';
--or following helps you seeing if there is an entry for your username
select * from piwik_option where option_name like '%defaultReport%';

Can you go to your user settings, select the default report to load again and press "Save". Does it change anything?

Is it otherwise possible, that the user you are testing, does not have access to any site? Or did not have access to a site for a few hours after creating the user?

@tsteur tsteur added this to the Piwik 2.14.0 milestone May 5, 2015
@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label May 5, 2015
@tsteur tsteur self-assigned this May 5, 2015
@tsteur tsteur modified the milestones: 2.13.1, Piwik 2.14.0 May 5, 2015
tsteur added a commit that referenced this issue May 5, 2015
@tsteur
Copy link
Member

tsteur commented May 6, 2015

Please reopen if you can still experience this issue after 2.13.1. Would be nice if you could still answer above questions. Maybe before updating to 2.13.1?

@tsteur tsteur closed this as completed May 6, 2015
@pouyana
Copy link
Author

pouyana commented May 7, 2015

Hi I was not checking sorry for the delay, the result of the your query:
+-----------------------+--------------+----------+
| option_name | option_value | autoload |
+-----------------------+--------------+----------+
| USERNAME_defaultReport | | 0 |
+-----------------------+--------------+----------+
1 row in set (0.00 sec)
Yes the user doesn’t have access to any sites when it was created. I just add the user after it was created to different sites.
The problem was that without the change I made, I was unable to see the setting as the user. but after the page is shown and I save the option once:
+-----------------------+--------------+----------+
| option_name | option_value | autoload |
+-----------------------+--------------+----------+
| USERNAME_defaultReport | 1 | 0 |
+-----------------------+--------------+----------+
1 row in set (0.00 sec)
it is saved.

@pouyana
Copy link
Author

pouyana commented May 7, 2015

So after the update the bug is solved thanks for the help :D

@tsteur
Copy link
Member

tsteur commented May 7, 2015

Thx for letting us know!

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.
Projects
None yet
Development

No branches or pull requests

2 participants