- md5
- 4c4c22b709aaacf80965f085152055b7
- sha1
- 34286403a72646e2fae95b3ddfb331e1840bae5d
- sha256
- 8298ad034f99855b227a7e656c1de8b0ea3324ab04c982eb476945c1a30ef920
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
<?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\CMS\Session\MetadataManager;
use Joomla\Console\AbstractCommand;
use Joomla\Database\DatabaseInterface;
use Joomla\Session\SessionInterface;
/**
* Console command for performing session metadata garbage collection
*
* @since 4.0.0
*/
class SessionMetadataGcCommand extends AbstractCommand
{
/**
* The database object.
*
* @var DatabaseInterface
* @since 4.0.0
*/
private $db;
/**
* The session object.
*
* @var SessionInterface
* @since 4.0.0
*/
private $session;
/**
* Instantiate the command.
*
* @param SessionInterface $session The session object.
* @param DatabaseInterface $db The database object.
*
* @since 4.0.0
*/
public function __construct(SessionInterface $session, DatabaseInterface $db)
{
$this->session = $session;
$this->db = $db;
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 Metadata Garbage Collection');
$sessionExpire = $this->session->getExpire();
(new MetadataManager($this->getApplication(), $this->db))->deletePriorTo(time() - $sessionExpire);
$symfonyStyle->success('Metadata garbage collection completed.');
return 0;
}
/**
* Initialise the command.
*
* @return void
*
* @since 4.0.0
*/
protected function initialise()
{
$this->setName('session:metadata:gc');
$this->setDescription('Performs session metadata garbage collection');
$this->setHelp(
<<<EOF
The <info>%command.name%</info> command runs the garbage collection operation for Joomla session metadata
<info>php %command.full_name%</info>
EOF
);
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.