Opened 14 months ago

Closed 6 months ago

Last modified 4 months ago

#3781 closed Bug (fixed)

getUserPreference bug: "defaultReport" preference is "false" by default

Reported by: tsteur Owned by: diosmosis
Priority: normal Milestone: 2.0.3 - Piwik 2.0.3
Component: Core Keywords:
Cc: Sensitive: no

Description

Hi,

I'm using the method "UsersManager.getUserPreference" via API to request a user's "defaultReport" preference. Depending on this I'll either display the "All Websites Dashboard" or the selected Website when a user opens the mobile app. Same behavior as in Piwik.

My problem:
After a fresh Piwik installation the API returns:

{value: false}

but should be:

{value: "1"}

Because Piwik behavior is to open first website after a fresh install and the value "Dashboard for a specific website -> FIRST WEBSITE" is selected by default in "User settings". Once I press "save" in "User settings" the API returns the correct value:

{value: "1"}

Is it possible to return the ID of the first website by default? Otherwise I'd have to implement a lot of stuff to workaround this and I'd have to do a lot of requests to make sure a website will be loaded.

API should always return either 'MultiSites' or an ID of a website.

Change History (14)

comment:1 Changed 14 months ago by matt (mattab)

  • Milestone changed from 1.12.x - Piwik 1.12.x to 1.12 - Piwik 1.12
  • Priority changed from normal to critical

comment:2 Changed 13 months ago by capedfuzz (diosmosis)

  • Owner set to diosmosis
  • Resolution set to fixed
  • Status changed from new to closed

In 0e35cd6d9e667fcf9b79ca9437c93f83f9d176d2:

Fixes #3781, make sure getUserPreference returns valid default value when option is not set in the DB.

comment:4 Changed 13 months ago by capedfuzz (diosmosis)

In 5879fbd3746e142f36351d5392b584c6f5ac8fdb:

Refs #3781, fixing build, revert last change and add getSuperUserLogin to Piwik_Access (so FakeAccess can mock it). Modified PDFReports to use Piwik::getSuperUserLogin instead of accessing config directly.

comment:5 Changed 13 months ago by capedfuzz (diosmosis)

In 24c2aa796cfd7101926be5de5d6d7dafcb9e4145:

Refs #3781, revert change to unrelated integration test.

comment:6 Changed 11 months ago by matt (mattab)

  • Priority changed from critical to normal
  • Summary changed from "defaultReport" preference is "false" by default to getUserPreference bug: "defaultReport" preference is "false" by default

comment:7 Changed 9 months ago by tsteur

  • Resolution fixed deleted
  • Status changed from closed to reopened

Is this really fixed? I just did a fresh install of Piwik and I'm still getting the response:

{value: false}

At least when using the Superuser. We also had such an issue in the current Piwik Mobile 2 beta test.

comment:8 Changed 9 months ago by matt (mattab)

  • Milestone changed from 1.12 - The Great 1.x Backlog to 2.0 - Piwik 2.0

comment:9 Changed 8 months ago by matt (mattab)

  • Type changed from New feature to Bug

comment:10 Changed 7 months ago by matt (mattab)

  • Milestone changed from 2.0 - Piwik 2.0 to Piwik 2.1

Piwik 2.0 full focus mode: Moving normal + low priorities to Piwik 2.1 milestone.

comment:11 Changed 6 months ago by tsteur

In 99a5f06b249c5f1f033af093ee497c7fafeaadfa:

refs #3781 fix superuser default preference is not returned by default, probably also fixes some login issues in Piwik Mobile as it is requesting the getSitesIdWithAtLeastViewAccess to verify whether someone has access to at least one website

comment:12 Changed 6 months ago by tsteur

  • Resolution set to fixed
  • Status changed from reopened to closed

comment:13 Changed 6 months ago by tsteur

In 43fd0f06a7f2e4149db805b990c55e119e88ba83:

refs #3781 fix test, defaultReport cannot return the website in case there is no website

comment:14 Changed 4 months ago by matt (mattab)

  • Milestone changed from 2.1 - Piwik 2.1 to 2.0.3 - Piwik 2.0.3
Note: See TracTickets for help on using tickets.