-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.0-dev' into bugfix/fix-js-tests
- Loading branch information
Showing
6 changed files
with
163 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 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 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Libraries | ||
* @subpackage Service | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Joomla\CMS\Service\Provider; | ||
|
||
defined('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\CMS\Console\SessionGcCommand; | ||
use Joomla\DI\Container; | ||
use Joomla\DI\ServiceProviderInterface; | ||
|
||
/** | ||
* Service provider for the application's console services | ||
* | ||
* @since 4.0 | ||
*/ | ||
class Console implements ServiceProviderInterface | ||
{ | ||
/** | ||
* Registers the service provider with a DI container. | ||
* | ||
* @param Container $container The DI container. | ||
* | ||
* @return void | ||
* | ||
* @since 4.0 | ||
*/ | ||
public function register(Container $container) | ||
{ | ||
$container->share( | ||
SessionGcCommand::class, | ||
function (Container $container) | ||
{ | ||
return new SessionGcCommand($container->get('session')); | ||
}, | ||
true | ||
); | ||
} | ||
} |