@mattab opened this Issue on July 9th 2015 Owner

Reported in forum: http://forum.piwik.org/read.php?2,127892

Error: Fatal error: Uncaught exception 'Piwik\Container\ContainerDoesNotExistException' with message 'The root container has not been created yet.'

This error can be found in Piwik demo script - http://demo.piwik.org/misc/others/api_internal_call.php

This script is documented in: https://developer.piwik.org/guides/querying-the-reporting-api (and currently broken, see second half of page)

I found the bug report also on WP forum - https://wordpress.org/support/topic/after-update-to-piwik-2140-no-stats-website-broken.

@mattab commented on July 12th 2015 Owner
@braekling commented on July 13th 2015

Hi @mattab - I applied the patch, but now I run into this:

Fatal error: Uncaught exception 'Piwik\Container\ContainerDoesNotExistException' with message 'The root container has not been created yet.' in /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php:40 Stack trace: <a href='/0'>#0</a> /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php(80): Piwik\Container\StaticContainer::getContainer() <a href='/1'>#1</a> /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(206): Piwik\Container\StaticContainer::get('path.tmp') <a href='/2'>#2</a> /var/www/vhosts/.../httpdocs/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request/Php.php(31): Piwik\FrontController->init() <a href='/3'>#3</a> /var/www/vhosts/.../httpdocs/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request/Php.php(14): WP_Piwik\Request\Php->call('method=VisitsSu...', 'http://www.brae...', 'module=API&form...') <a href='/4'>#4</a> /var/www/vhosts/.../httpdocs/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request.php(63): WP_Piwik\Request\Php->request('method=VisitsSu...') <a href='/5'>#5</a> /var/www/vhosts/.../httpdocs/wp- in /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php on line 40

Fatal error: Uncaught exception 'Piwik\Container\ContainerDoesNotExistException' with message 'The root container has not been created yet.' in /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php:40 Stack trace: <a href='/0'>#0</a> /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php(80): Piwik\Container\StaticContainer::getContainer() <a href='/1'>#1</a> /var/www/vhosts/.../httpdocs/stats/core/Config.php(62): Piwik\Container\StaticContainer::get('Piwik\Config') <a href='/2'>#2</a> /var/www/vhosts/.../httpdocs/stats/core/Url.php(347): Piwik\Config::getInstance() <a href='/3'>#3</a> /var/www/vhosts/.../httpdocs/stats/core/Url.php(67): Piwik\Url::getCurrentHost() <a href='/4'>#4</a> /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(87): Piwik\Url::getCurrentUrl() <a href='/5'>#5</a> /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(181): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array) <a href='/6'>#6</a> [internal function]: Piwik\FrontController::triggerSafeModeWhenError() <a href='/7'>#7</a> {main} thrown in /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php on line 40

Maybe I miss something? This is how I init the FrontController:

if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
   require_once PIWIK_INCLUDE_PATH . "/index.php";
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
   require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
if (class_exists('Piwik\FrontController'))
   \Piwik\FrontController::getInstance()->init();

I'm not able to get WP-Piwik working again since Piwik 2.14.0.

@propertunist commented on July 13th 2015

i just tested this fix with my problem (api renderer format not valid) and am still seeing the same error in the log:

PHP message: Exception <a href='/1436824607'>#1436824607</a>: exception 'Exception' with message 'Renderer format 'json' not valid. Try any of the following instead: .' in /var/www/piwik/core/API/ApiRenderer.php:123
Stack trace:
<a href='/0'>#0</a> /var/www/piwik/core/API/ResponseBuilder.php(40): Piwik\API\ApiRenderer::factory('json', Array)
<a href='/1'>#1</a> /var/www/piwik/core/API/Request.php(211): Piwik\API\ResponseBuilder->__construct('json', Array)
<a href='/2'>#2</a> /mysite/lib/functions.php(82): Piwik\API\Request->process()
<a href='/3'>#3</a> /mysite/lib/functions.php(89): piwik_get_country_from_ip()
<a href='/4'>#4</a> /mysite/menu/site.php(169): get_area_code_from_ip_data()
@mattab commented on July 14th 2015 Owner
@mattab commented on July 14th 2015 Owner

@propertunist what is your problem, the error message seems un-related? what is your script generating this error?

@propertunist commented on July 14th 2015

i am referring to this issue, which was marked as a duplicate of #8311:
https://github.com/piwik/piwik/issues/8333

@mattab commented on July 14th 2015 Owner

@propertunist do you have the script source code used to reproduce this bug?

@propertunist commented on July 14th 2015

do you need more than i already provided in the other ticket? e.g.

$request = new Request ('
module=API
&method=UserCountry.getLocationFromIP
&ip=' . $current_IP . '
&format=json
&token_auth=' . $piwik_secret
);
@braekling commented on July 14th 2015

@mattab Adding these lines to my code causes the same issue as reported by @propertunist #8333:

Fatal error: Uncaught exception 'Exception' with message 'Renderer format 'php' not valid.

(If I test my current development branch which already uses json, I get the related error message: Renderer format 'json' not valid.)

@propertunist commented on July 16th 2015

this issue has not been fixed for me in 2.14.1.
i have run the upgrade and i still see exactly the same fatal errors when running an API call. the 2.14 workaround still changes the fatal error from the 'root container has not been created yet' message to the 'renderer format not valid: 'json'' message. but ultimately the outcome remains - fatal error.

@mattab commented on July 16th 2015 Owner

@braekling @propertunist the script api_internal_call.php is working now: http://demo.piwik.org/misc/others/api_internal_call.php

please create a new issue for your problem and we will investigate - i'll set it to 2.14.2 milestone (since it looks like we will have another dot release later). thanks

@mattab commented on July 16th 2015 Owner

in the issue, it would really help if you can write a minimal script that we can use to reproduce your issue

@propertunist commented on July 16th 2015

ok, i have provided that info in a new ticket here: https://github.com/piwik/piwik/issues/8365

@braekling commented on July 19th 2015

To keep this clear, I added my script excerpt to @propertunist new ticket, too. #8365

This Issue was closed on July 12th 2015
Powered by GitHub Issue Mirror