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/cron/archive.php ignoring PIWIK_USER_PATH set in /bootstrap.php #20327

Open
Cangoo opened this issue Feb 7, 2023 · 2 comments
Open

/misc/cron/archive.php ignoring PIWIK_USER_PATH set in /bootstrap.php #20327

Cangoo opened this issue Feb 7, 2023 · 2 comments
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.

Comments

@Cangoo
Copy link

Cangoo commented Feb 7, 2023

I use to define my own PIWIK_USER_PATH in /bootstrap.php to alter the path of the config.ini.php-file. But when calling /misc/cron/archive.php PIWIK_USER_PATH is already set BEFORE /bootstrap.php is called.

Expected Behavior

/bootstrap.php should be called before PIWIK_USER_PATH is set in /misc/cron/archive.php

Current Behavior

/bootstrap.php is called AFTER PIWIK_USER_PATH is already set in /misc/cron/archive.php

Possible Solution

/misc/cron/archive.php

if (!defined('PIWIK_DOCUMENT_ROOT')) {
    define('PIWIK_DOCUMENT_ROOT', realpath(dirname(__FILE__) . "/../.."));
}

// Added
if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) {
	require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
}
// /Added

if (!defined('PIWIK_INCLUDE_PATH')) {
    define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT);
}

if (!defined('PIWIK_USER_PATH')) {
    define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
}

Steps to Reproduce (for Bugs)

Create a /bootstrap.php-file with this content:
define('PIWIK_USER_PATH', $_SERVER['DOCUMENT_ROOT'].'/my-new-path-to-matomo-config/');

Move config.ini.php to $_SERVER['DOCUMENT_ROOT'].'/my-new-path-to-matomo-config/'

call /misc/cron/archive.php

=> Warning: Constant PIWIK_USER_PATH already defined in ...\matomo\bootstrap.php on line 1
=> cron-job is not working, instead the installation-page is shown

Context

I'm moving the config-file to another location, because I want to use matomo on different servers and don't want to override the config.ini.php on updates.

@Cangoo Cangoo added Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels Feb 7, 2023
@Cangoo Cangoo changed the title /misc/cron/archive.php ignoring PIWIK_USER_PATH SET in /bootstrap.php /misc/cron/archive.php ignoring PIWIK_USER_PATH set in /bootstrap.php Feb 7, 2023
@sgiehl
Copy link
Member

sgiehl commented Feb 7, 2023

Hi @Cangoo. Thanks for this report. It seems the archive.php current does not even try to include a custom bootstrap file.

@tsteur Do you know any reason why we don't include a custom bootstrap file there?

@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/web-cron-your-browser-was-unable-to-load-the-scripts-of-this-page/49619/3

@sgiehl sgiehl added this to the For Prioritization milestone Feb 9, 2023
@sgiehl sgiehl removed the To Triage An issue awaiting triage by a Matomo core team member label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.
Projects
None yet
Development

No branches or pull requests

4 participants