Skip to content

Commit

Permalink
refs matomo-org#4439 disable eAccelerator if enabled (just disabling …
Browse files Browse the repository at this point in the history
…optimizing did not work) and display a message in the admin UI. Also disabled eAccelerator during tracking. We might need to move the method to detect eAccelerator to another place, not sure if this is the best one
  • Loading branch information
tsteur committed Feb 6, 2014
1 parent 277af28 commit ab6070f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
34 changes: 34 additions & 0 deletions core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*/
abstract class ControllerAdmin extends Controller
{
private static $isEacceleratorUsed = false;

private static function notifyWhenTrackingStatisticsDisabled()
{
$statsEnabled = PiwikConfig::getInstance()->Tracker['record_statistics'];
Expand Down Expand Up @@ -97,6 +99,37 @@ static public function displayWarningIfConfigFileNotWritable()
}
}

/**
* See http://dev.piwik.org/trac/ticket/4439#comment:8 and https://github.com/eaccelerator/eaccelerator/issues/12
*
* Eaccelerator does not support closures and is known to be not comptabile with Piwik. Therefore we are disabling
* it automatically. At this point it looks like Eaccelerator is no longer under development and the bug has not
* been fixed within a year.
*/
public static function disableEacceleratorIfEnabled()
{
$isEacceleratorUsed = ini_get('eaccelerator.enable');

if (!empty($isEacceleratorUsed)) {
self::$isEacceleratorUsed = true;

@ini_set('eaccelerator.enable', 0);
}
}

private static function notifyIfEAcceleratorIsUsed()
{
if (self::$isEacceleratorUsed) {
$params = array('<a href="http://dev.piwik.org/trac/ticket/4439">', '</a>');
$message = Piwik::translate('CoreAdminHome_EacceleratorNotCompatible', $params);

$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
$notification->raw = true;
Notification\Manager::notify('ControllerAdmin_EacceleratorIsUsed', $notification);
}
}

/**
* Assigns view properties that would be useful to views that render admin pages.
*
Expand All @@ -123,6 +156,7 @@ static public function displayWarningIfConfigFileNotWritable()
static public function setBasicVariablesAdminView(View $view)
{
self::notifyWhenTrackingStatisticsDisabled();
self::notifyIfEAcceleratorIsUsed();

$view->topMenu = MenuTop::getInstance()->getMenu();
$view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName();
Expand Down
3 changes: 3 additions & 0 deletions core/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Piwik\Error;
use Piwik\ExceptionHandler;
use Piwik\FrontController;
use \Piwik\Plugin\ControllerAdmin as PluginControllerAdmin;

PluginControllerAdmin::disableEacceleratorIfEnabled();

if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) {
require_once PIWIK_INCLUDE_PATH . '/core/Error.php';
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@
"PluginSettingsIntro": "Here you can change the settings for the following 3rd party plugins:",
"PluginSettingsValueNotAllowed": "The value for field \"%s\" in plugin \"%s\" is not allowed",
"PluginSettingChangeNotAllowed": "You are not allowed to change the value of the setting \"%s\" in plugin \"%s\"",
"PluginSettings": "Plugin settings"
"PluginSettings": "Plugin settings",
"EacceleratorNotCompatible": "You are using the PHP accelerator & optimizer eAccelerator which is known to be not compatible with Piwik. We have disabled eAccelerator therefore which might affect the performance of Piwik. Read the %srelated ticket%s for more information and how to fix this problem."
},
"CoreHome": {
"InjectedHostWarningIntro": "You are now accessing Piwik from %1$s, but Piwik has been configured to run at this address: %2$s.",
Expand Down
6 changes: 6 additions & 0 deletions piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

@ignore_user_abort(true);

require_once PIWIK_INCLUDE_PATH . '/core/Plugin/Controller.php';
require_once PIWIK_INCLUDE_PATH . '/core/Plugin/ControllerAdmin.php';

\Piwik\Plugin\ControllerAdmin::disableEacceleratorIfEnabled();

require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php';
require_once PIWIK_INCLUDE_PATH . '/core/Singleton.php';
Expand Down Expand Up @@ -78,6 +83,7 @@
if (!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) {
ob_start();
}

if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) {
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';

Expand Down

0 comments on commit ab6070f

Please sign in to comment.