CoreFiles by mySites.guru
SessionGcCommand.php89 lines, 1,768 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
a6bafdce63b4eb03198590cc272e71c9
sha1
a7fe725328343a518be2d4b3b0ea83c5891578be
sha256
37c2a10511e5265776062616ae641dd52be6304ffafa8963e75060976ba42f19
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Console;

defined('JPATH_PLATFORM') or die;

use Joomla\Console\AbstractCommand;
use Joomla\Session\SessionInterface;

/**
 * Console command for performing session garbage collection
 *
 * @since  4.0.0
 */
class SessionGcCommand extends AbstractCommand
{
	/**
	 * The session object.
	 *
	 * @var    SessionInterface
	 * @since  4.0.0
	 */
	private $session;

	/**
	 * Instantiate the command.
	 *
	 * @param   SessionInterface  $session  The session object.
	 *
	 * @since   4.0.0
	 */
	public function __construct(SessionInterface $session)
	{
		$this->session = $session;

		parent::__construct();
	}

	/**
	 * Execute the command.
	 *
	 * @return  integer  The exit code for the command.
	 *
	 * @since   4.0.0
	 */
	public function execute(): int
	{
		$symfonyStyle = $this->createSymfonyStyle();

		$symfonyStyle->title('Running Session Garbage Collection');

		if ($this->session->gc() === false)
		{
			$symfonyStyle->error('Garbage collection was not completed. Either the operation failed or is not supported on your platform.');

			return 1;
		}

		$symfonyStyle->success('Garbage collection completed.');

		return 0;
	}

	/**
	 * Initialise the command.
	 *
	 * @return  void
	 *
	 * @since   4.0.0
	 */
	protected function initialise()
	{
		$this->setName('session:gc');
		$this->setDescription('Performs session garbage collection');
		$this->setHelp(
<<<EOF
The <info>%command.name%</info> command runs PHP's garbage collection operation for session data

<info>php %command.full_name%</info>
EOF
		);
	}
}

No other release has this exact content. See every version of this file.