Settings => All Websites doesn't show websites for superuser

Hallo everybody,

We are hosting a very large enterprise installation of Piwik and we just did a test update from 1.12 to 2.6.1. Everything works so far, except that the site Settings => All Websites doesn’t show any websites although I’m logged in as super user:
[attachment 1922 screenshot.png]

I tried to debug this issue. The problem is that this request doesn’t give any results:
/index.php?date=yesterday&fetchAliasUrls=true&format=JSON2&idSite=1&method=SitesManager.getSitesWithAdminAccess&module=API&period=day

These are the request details (from Chrome dev tools):
[attachment 1924 screenshot2.png]

I set a log statement to SitesManager\API.php in the method getSitesWithAdminAccess and it retrieves the correct sites (all of them because I’m superuser):


public function getSitesWithAdminAccess($fetchAliasUrls = false)
{
    $sitesId = $this->getSitesIdWithAdminAccess();
    $sites = $this->getSitesFromIds($sitesId);

    if ($fetchAliasUrls)
        foreach ($sites as &$site)
            $site['alias_urls'] = API::getInstance()->getSiteUrlsFromId($site['idsite']);
	// here, $sites is a huge array with more than 1000 sites
    return $sites;
}


However, the request doesn’t get any JSON response ( Content-Length:0 ). The strange thing is that I can make this request if I set the format parameter to “XML” instead of “JSON2”. It works when I just put it in the browser address bar, so it doesn’t even care if it’s a GET request instead of a POST. As soon as I set format=JSON2, it doesn’t work again.

I think we really need help here!

Regards,
Felix

Do you see any error in error log?

Unfortunately not. Although I set everything to DEBUG level in the config file:


[log]
log_writers[] = "file"
log_level = "DEBUG"
logger_file_path = "E:\logs\piwik.log"
logger_message[] = "file"
logger_error[] = "file"
logger_exception[] = "file"

Also, when I insert Log::debug(“something”); in the source code, it is logged into this file, so logging in general is definitely working.

Some more information:
[ul]
[li] Internet Information Services 7.5
[/li][li] Windows Server R2
[/li][li] Default installation currently without third-party plugins
[/li][/ul]

Other requests with format=JSON2 work well, so it’s no JSON/Webserver related issue.

OK for PIwik log. But maybe you see an error in the IIS server error log? It’s strange that it would return nothing at all. Maybe try with 2.7.0-rc1 ?
download from: Index of /

I just updated to Piwik 2.7 and the problem still exists. There is nothing shown in the IIS error log. The request get a 200 OK anyway. The response is just empty. Any ideas where I can look in the source code? I really have no clue at the moment.

Umh that’s very strange. Is this API the only api that does not return proper data?

Yes, the other API methods work fine and I get a valid JSON response. I now tried to remove superuser access from my account:


UPDATE piwik_user
SET superuser_access = 0
WHERE login = 'myaccount';

Although I have “admin” permissions on all sites, there is still no result. I checked with:


SELECT * FROM piwik_access WHERE login = "myaccount";

Where else can I dig to find out the source of this problem??

I have the same problem with my installation. If I log in as a different user with restricted access to ony one website the website is shown in the list.

Interesting! This means it’s not something we did wrong in our environment, but it’s probably kind of a problem in Piwik. I hope someone can help soon because this is really a serious problem that keeps us from updating…

unfortunately we couldn’t reproduce so far, but we want to help fix the issue for you!

when I insert Log::debug("something"winking smiley; in the source code, it is logged into this file, so logging in general is definitely working.

Actually by error log I meant your webserver IIS error log → maybe theres an error logged there when you get that blank response?

Otherwise, does it work if you set format=json instead of json2 ?

Hi Matt!

Thank you for your help - really appreciated! As I stated earlier, there is nothing printed in the IIS error log. Also, it’s a 200 OK response, so it doesn’t look like anything could be wrong from a webserver perspective.

Let me state again the facts for this URL:
http://mypiwikhost/index.php?date=yesterday&fetchAliasUrls=true&format=JSON2&idSite=1&method=SitesManager.getSitesWithAdminAccess&module=API&period=day&token_auth=XXXXXXXXX

[ul]
[li] When the Ajax request from the Piwik Admin => All websites interface is sent, the response is emtpy, Content-Length:0
[/li]Content-Type:application/json; charset=utf-8. The token_auth parameter is the only one sent as “Form Data”
[li] When I type this URL in the browser, the response is empty, Content-Length:0
[/li]Content-Type:application/json; charset=utf-8
[li] When I use format=JSON instead of JSON2, the result is exactly the same
[/li][li] When I use format=XML in the browser bar, the result is the correct (very big) XML result
[/li][li] When I omit the token_auth parameter, the result is an empty JSON array, Content-Length:2
[/li]Content-Type:application/json; charset=utf-8
[/ul]

The strange thing is that the response won’t be empty for users that have only a few sites with admin permissions. I get the feeling that this is somehow related to the JSON size. But webserver-wise, everything’s ok, so probably this happens somewhere in the application layer. I will dig in some more now.

I’d be glad if you had another look too.

Actually I observed this interesting behavior now:
[ul]
[li] When I remove the superuser setting from my user, it still doesn’t work
[/li][li] When I set all permissions on my user to “view”, I get an empty JSON array
[/li][li] When I set the first 100 sites on my user to “admin”, I get the correct JSON for the 100 sites
[/li][li] With 350 sites, it still works, the response content-length is 157788
[/li][li] With 400 sites, the response is empty again
[/li][/ul]

I’m really curious now whether the problem occurs on IIS-side or Piwik-side…

this problem is either on IIS side or PHP side but not piwik.

Maybe try upgrading your PHP version? sometimes old versions are buggy.

Maybe try upgrading memory of your piwik, to 512M or 10124M?

I’m using PHP 5.5.10 which shouldn’t be a buggy version. And the memory_limit is set to 2048M.

I finally found the source of the problem! The response is empty if any site in the piwik_site table has an umlaut in its name. In my case, some pages had “ä”, “ü”, “ö” (German) in its name. As soon as I replaced all the umlauts, I got the correct JSON response. Note that the umlauts were no problem at all with format=XML. Also, I think it’s not permitted per se to have umlauts in site names, right? Otherwise we probably wouldn’t have been able to create these pages. So finally I conclude that this is actually kind of a bug in Piwik. No offense ;-).

What do you think? Should I rename these pages? It’s actually not that easy, because we have a job that automatically runs through a list of intranet pages (export from sharepoint) and creates Piwik sites for these pages if they don’t yet exist. So it’s kind of all wired up with these umlaut-names :frowning:

hmm. Where can I find this piwik_site table?

(thx for the research by the way)

It’s in your database. You can do


SELECT name FROM piwik_site;

Then check if there are umlauts somewhere. Are you German? Then it might also be äöü and so on…

Matt, you don’t have any further help for me? I think this is clearly a bug in Piwik…

if you are not yet using latest version of your web server, try upgrading first maybe it helps.

Same with upgrading PHP Version to latest.

if all is updated and still issue then Could you please create a bug report on the Issue tracker as this post is getting very long?

I raised an issue on GitHub here: