create a cli class that extends from JApplicationCli and put JFactory::getUser() in doExecute method
run the file from command line
Im not sure this happend in older version too or not
i need to run JHtml::('date', $date, JText::('DATE_FORMAT_LC2')) from CLI
Priority | Critical | ⇒ | Medium |
Code to reproduce this bug, save this gist to /cli/test15876.php and run at the command line
<?php
/**
* @package Joomla.Cli
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// We are a valid entry point.
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
// Configure error reporting to maximum for CLI output.
error_reporting(E_ALL);
ini_set('display_errors', 1);
/**
* A command line cron job to attempt to remove files that should have been deleted at update.
*
* @since 3.0
*/
class Test15876Cli extends JApplicationCli
{
/**
* Entry point for CLI script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
var_dump(JHtml::_('date', time(), JText::_('DATE_FORMAT_LC2')) );
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('Test15876Cli')->execute();
Testing in PHP 5.6 and 5.3 with Joomla 3.7.0 gives the same issue.
Problem comes from JFactory::getUser(); and from getSession()
Status | New | ⇒ | Discussion |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-08 17:39:35 |
Closed_By | ⇒ | mbabker |
Cannot replicate with the facts provided.
JFactory::getUser()
doesnt cause an issue for me at all.However, reading between the lines this is NOT a problem with
JFactory::getUser()
but a problem with the JDate in Joomla 3.7.0Running
with PHP 7.1 CLI - I get
Error displaying the error page: Application Instantiation Error: Application Instantiation Error