CoreFiles by mySites.guru
eaccelerator.php83 lines, 2,614 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
49febcb9636abe78631117dc2bcce162
sha1
cd52b88c60fcfb82343f5081adfdaf038ca106c3
sha256
e8fc24b26661f2c6a47f4ca7dcc75562cd98c962512caf64e44b8eb0ac77d8a1
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_admin
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 *
 * This file contains post-installation message handling for eAccelerator compatibility.
 */

defined('_JEXEC') or die;

use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

/**
 * Checks if the eAccelerator caching method is enabled.
 *
 * This check should be done through the 3.x series as the issue impacts migrated sites which will
 * most often come from the previous LTS release (2.5). Remove for version 4 or when eAccelerator support is added.
 *
 * This check returns true when the eAccelerator caching method is user, meaning that the message concerning it should be displayed.
 *
 * @return  integer
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_condition()
{
	$app = Factory::getApplication();
	$cacheHandler = $app->get('cacheHandler', '');

	return (ucfirst($cacheHandler) == 'Eaccelerator');
}

/**
 * Disables the unsupported eAccelerator caching method, replacing it with the "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
	$prev = ArrayHelper::fromObject(new JConfig);
	$data = array_merge($prev, array('cacheHandler' => 'file'));

	$config = new Registry($data);

	// Set the configuration file path.
	$file = JPATH_CONFIGURATION . '/configuration.php';

	// Get the new FTP credentials.
	$ftp = ClientHelper::getCredentials('ftp', true);

	// Attempt to make the file writeable if using FTP.
	if (!$ftp['enabled'] && Path::isOwner($file) && !Path::setPermissions($file, '0644'))
	{
		Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'notice');
	}

	// Attempt to write the configuration file as a PHP class named JConfig.
	$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));

	if (!File::write($file, $configuration))
	{
		Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');

		return;
	}

	// Attempt to make the file unwriteable if using FTP.
	if (!$ftp['enabled'] && Path::isOwner($file) && !Path::setPermissions($file, '0444'))
	{
		Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'notice');
	}
}

The same content is in 6 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha12. See them all, or every version of this file.