@Jako opened this Issue on December 28th 2008

I've got a warning message if I use the API from a different domain on the same server.

Warning: Invalid argument supplied for foreach() in /users/XXXXXXX/data/websites/myDomain/plugins/LanguagesManager/API.php on line 34

The Piwik installation is located on '/users/XXXXXXX/data/websites/myDomain' on the server and I call the Piwik API from a different domain (roor: '/users/XXXXXXX/data/websites/mySecondDomain') on the same server with the Internal PHP calling example in the wiki.

After the warning messages the result of the API is displayed correctly.

I think the line 32 in /plugins/LanguagesManager/API.php

$languages = glob( "lang/*");

points to a wrong folder if the API-call is not executed in the piwik Folder.
Keywords: api,warning,internal

@robocoder commented on December 31st 2008 Contributor

Attachment:
483.patch

@robocoder commented on January 14th 2009 Contributor

Attachment: Modified example from wiki.
testing.php

@Jako commented on December 31st 2008

Seems not to work.

$olddir: '/users/XXXXXXX/data/websites/MyDomain'
$_SERVER['SCRIPT_FILENAME']: '/users/XXXXXXX/data/websites/myDomain/testing.php'

In testing.php piwik is executed by including (see the example in the wiki):

define('PIWIK_INCLUDE_PATH', '/users/XXXXXXX/data/websites/MyPiwikDomain');
define('ENABLE_DISPATCH', false);    
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
@Jako commented on December 31st 2008

Maybe something like this:

$olddir = getcwd();
if (defined ('PIWIK_INCLUDE_PATH'))
    chdir(PIWIK_INCLUDE_PATH);
$languages = glob( "lang/*");
chdir( $olddir );
@robocoder commented on December 31st 2008 Contributor

Here's a simpler patch.

@mattab commented on January 14th 2009 Owner

vipsoft and Jako, did you test the patch with the use case? Please confirm before commit. Thanks

@robocoder commented on January 14th 2009 Contributor

I didn't hear back from Jako, but I tested the patch (in the attachment).

@mattab commented on January 14th 2009 Owner

thanks for patch Anthon. Fixed in [877](just slight style changes)

@Jako commented on January 14th 2009

Sorry for answering late. The patch works for me. Thanks!

This Issue was closed on January 14th 2009
Powered by GitHub Issue Mirror