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

misc/others/api_internal_call.php is broken #8311

Closed
mattab opened this issue Jul 9, 2015 · 14 comments
Closed

misc/others/api_internal_call.php is broken #8311

mattab opened this issue Jul 9, 2015 · 14 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Jul 9, 2015

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 mattab added Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. labels Jul 9, 2015
@mattab mattab added this to the 2.14.1 milestone Jul 9, 2015
DCbrain added a commit to DCbrain/wp-piwik that referenced this issue Jul 12, 2015
Workaround to avoid this : matomo-org/matomo#8311. Error: Fatal error: Uncaught exception 'Piwik\Container\ContainerDoesNotExistException' with message 'The root container has not been created yet.'
No regression test done.
I pick corrections  here : http://forum.piwik.org/read.php?2,127892.Fully functional in 3 different instances of piwik.
mattab added a commit that referenced this issue Jul 12, 2015
@mattab
Copy link
Member Author

mattab commented Jul 12, 2015

fixed in 47cf782

@mattab mattab closed this as completed Jul 12, 2015
diosmosis pushed a commit that referenced this issue Jul 12, 2015
…xample script. Includes new proxy script that will call another script using Piwik's test environment, but w/o actually setting up the test env.
@braekling
Copy link

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: #0 /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php(80): Piwik\Container\StaticContainer::getContainer() #1 /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(206): Piwik\Container\StaticContainer::get('path.tmp') #2 /var/www/vhosts/.../httpdocs/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request/Php.php(31): Piwik\FrontController->init() #3 /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...') #4 /var/www/vhosts/.../httpdocs/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request.php(63): WP_Piwik\Request\Php->request('method=VisitsSu...') #5 /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: #0 /var/www/vhosts/.../httpdocs/stats/core/Container/StaticContainer.php(80): Piwik\Container\StaticContainer::getContainer() #1 /var/www/vhosts/.../httpdocs/stats/core/Config.php(62): Piwik\Container\StaticContainer::get('Piwik\Config') #2 /var/www/vhosts/.../httpdocs/stats/core/Url.php(347): Piwik\Config::getInstance() #3 /var/www/vhosts/.../httpdocs/stats/core/Url.php(67): Piwik\Url::getCurrentHost() #4 /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(87): Piwik\Url::getCurrentUrl() #5 /var/www/vhosts/.../httpdocs/stats/core/FrontController.php(181): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array) #6 [internal function]: Piwik\FrontController::triggerSafeModeWhenError() #7 {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
Copy link

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 #1436824607: 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:
#0 /var/www/piwik/core/API/ResponseBuilder.php(40): Piwik\API\ApiRenderer::factory('json', Array)
#1 /var/www/piwik/core/API/Request.php(211): Piwik\API\ResponseBuilder->__construct('json', Array)
#2 /mysite/lib/functions.php(82): Piwik\API\Request->process()
#3 /mysite/lib/functions.php(89): piwik_get_country_from_ip()
#4 /mysite/menu/site.php(169): get_area_code_from_ip_data()

@mattab
Copy link
Member Author

mattab commented Jul 14, 2015

@braekling maybe you need to add same two lines as in 47cf782 ?

@mattab
Copy link
Member Author

mattab commented Jul 14, 2015

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

@propertunist
Copy link

i am referring to this issue, which was marked as a duplicate of #8311:
#8333

@mattab
Copy link
Member Author

mattab commented Jul 14, 2015

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

@propertunist
Copy link

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
Copy link

@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
Copy link

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
Copy link
Member Author

mattab commented Jul 16, 2015

@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
Copy link
Member Author

mattab commented Jul 16, 2015

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

@propertunist
Copy link

ok, i have provided that info in a new ticket here: #8365

@braekling
Copy link

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

pluginmirror-worker pushed a commit to wp-plugins/wp-piwik that referenced this issue Jul 21, 2015
* Several language updates.
* Switch to JSON renderer (Piwik 3 compatibility preparation)
* Workaround: PHP API will work with Piwik 2.14+, see matomo-org/matomo#8311 for further information.
* Feature: Heartbeat timer support
* Bugfix: Site duplication fix.
* Bugfix: Avoid notice on empty overview response.
* Bugfix: Return request error responses.

git-svn-id: https://plugins.svn.wordpress.org/wp-piwik/trunk@1202986 b8457f37-d9ea-0310-8a92-e5e31aec5664
pluginmirror-worker pushed a commit to wp-plugins/wp-piwik that referenced this issue Jul 21, 2015
* Several language updates.
* Switch to JSON renderer (Piwik 3 compatibility preparation)
* Workaround: PHP API will work with Piwik 2.14+, see matomo-org/matomo#8311 for further information.
* Feature: Heartbeat timer support
* Bugfix: Site duplication fix.
* Bugfix: Avoid notice on empty overview response.
* Bugfix: Return request error responses.

git-svn-id: https://plugins.svn.wordpress.org/wp-piwik/trunk@1202989 b8457f37-d9ea-0310-8a92-e5e31aec5664
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. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

No branches or pull requests

3 participants