diff --git a/installation/src/Service/Provider/Application.php b/installation/src/Service/Provider/Application.php index b8da47fb3b480..dab5283f079c8 100644 --- a/installation/src/Service/Provider/Application.php +++ b/installation/src/Service/Provider/Application.php @@ -11,13 +11,13 @@ namespace Joomla\CMS\Installation\Service\Provider; use Joomla\CMS\Error\Renderer\JsonRenderer; -use Joomla\CMS\Input\Input as CMSInput; use Joomla\CMS\Installation\Application\CliInstallationApplication; use Joomla\CMS\Installation\Application\InstallationApplication; use Joomla\CMS\Language\LanguageFactoryInterface; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use Joomla\Event\Priority; +use Joomla\Input\Input as CMSInput; use Joomla\Session\SessionEvents; use Joomla\Session\SessionInterface; use Psr\Log\LoggerInterface; diff --git a/libraries/src/Input/Cli.php b/libraries/src/Input/Cli.php index 443202f6e9ee8..7d56b9202a0e7 100644 --- a/libraries/src/Input/Cli.php +++ b/libraries/src/Input/Cli.php @@ -10,6 +10,7 @@ namespace Joomla\CMS\Input; use Joomla\CMS\Filter\InputFilter; +use Joomla\Input\Input; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; diff --git a/libraries/src/Input/Cookie.php b/libraries/src/Input/Cookie.php deleted file mode 100644 index 09acbdb351d09..0000000000000 --- a/libraries/src/Input/Cookie.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\CMS\Input; - -use Joomla\CMS\Filter\InputFilter; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * Joomla! Input Cookie Class - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Cookie instead - */ -class Cookie extends Input -{ - /** - * Constructor. - * - * @param array $source Ignored. - * @param array $options Array of configuration parameters (Optional) - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Cookie instead - */ - public function __construct(array $source = null, array $options = []) - { - if (isset($options['filter'])) { - $this->filter = $options['filter']; - } else { - $this->filter = InputFilter::getInstance(); - } - - // Set the data source. - $this->data = &$_COOKIE; - - // Set the options for the class. - $this->options = $options; - } - - /** - * Sets a value - * - * @param string $name Name of the value to set. - * @param mixed $value Value to assign to the input. - * @param array $options An associative array which may have any of the keys expires, path, domain, - * secure, httponly and samesite. The values have the same meaning as described - * for the parameters with the same name. The value of the samesite element - * should be either Lax or Strict. If any of the allowed options are not given, - * their default values are the same as the default values of the explicit - * parameters. If the samesite element is omitted, no SameSite cookie attribute - * is set. - * - * @return void - * - * @link http://www.ietf.org/rfc/rfc2109.txt - * @see setcookie() - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Cookie instead - */ - public function set($name, $value, $options = []) - { - // BC layer to convert old method parameters. - if (\is_array($options) === false) { - trigger_deprecation( - 'joomla/input', - '1.4.0', - 'The %s($name, $value, $expire, $path, $domain, $secure, $httpOnly) signature is deprecated and' - . ' will not be supported once support' - . ' for PHP 7.2 and earlier is dropped, use the %s($name, $value, $options) signature instead', - __METHOD__, - __METHOD__ - ); - - $argList = \func_get_args(); - - $options = [ - 'expires' => $argList[2] ?? 0, - 'path' => $argList[3] ?? '', - 'domain' => $argList[4] ?? '', - 'secure' => $argList[5] ?? false, - 'httponly' => $argList[6] ?? false, - ]; - } - - // Set the cookie - if (version_compare(PHP_VERSION, '7.3', '>=')) { - if (\is_array($value)) { - foreach ($value as $key => $val) { - setcookie($name . "[$key]", $val, $options); - } - } else { - setcookie($name, $value, $options); - } - } else { - // Using the setcookie function before php 7.3, make sure we have default values. - if (\array_key_exists('expires', $options) === false) { - $options['expires'] = 0; - } - - if (\array_key_exists('path', $options) === false) { - $options['path'] = ''; - } - - if (\array_key_exists('domain', $options) === false) { - $options['domain'] = ''; - } - - if (\array_key_exists('secure', $options) === false) { - $options['secure'] = false; - } - - if (\array_key_exists('httponly', $options) === false) { - $options['httponly'] = false; - } - - if (\is_array($value)) { - foreach ($value as $key => $val) { - setcookie( - $name . "[$key]", - $val, - $options['expires'], - $options['path'], - $options['domain'], - $options['secure'], - $options['httponly'] - ); - } - } else { - setcookie( - $name, - $value, - $options['expires'], - $options['path'], - $options['domain'], - $options['secure'], - $options['httponly'] - ); - } - } - - $this->data[$name] = $value; - } -} diff --git a/libraries/src/Input/Files.php b/libraries/src/Input/Files.php deleted file mode 100644 index 17e5722c499fb..0000000000000 --- a/libraries/src/Input/Files.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\CMS\Input; - -use Joomla\CMS\Filter\InputFilter; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * Joomla! Input Files Class - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ -class Files extends Input -{ - /** - * The pivoted data from a $_FILES or compatible array. - * - * @var array - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ - protected $decodedData = []; - - /** - * The class constructor. - * - * @param array $source The source argument is ignored. $_FILES is always used. - * @param array $options An optional array of configuration options: - * filter : a custom InputFilter object. - * - * @since 3.0.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ - public function __construct(array $source = null, array $options = []) - { - if (isset($options['filter'])) { - $this->filter = $options['filter']; - } else { - $this->filter = InputFilter::getInstance(); - } - - // Set the data source. - $this->data = &$_FILES; - - // Set the options for the class. - $this->options = $options; - } - - /** - * Gets a value from the input data. - * - * @param string $name The name of the input property (usually the name of the files INPUT tag) to get. - * @param mixed $default The default value to return if the named property does not exist. - * @param string $filter The filter to apply to the value. - * - * @return mixed The filtered input value. - * - * @see InputFilter::clean() - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ - public function get($name, $default = null, $filter = 'cmd') - { - if (isset($this->data[$name])) { - $results = $this->decodeData( - [ - $this->data[$name]['name'], - $this->data[$name]['type'], - $this->data[$name]['tmp_name'], - $this->data[$name]['error'], - $this->data[$name]['size'], - ] - ); - - // Prevent returning an unsafe file unless specifically requested - if (strtoupper($filter) !== 'RAW') { - $isSafe = InputFilter::isSafeFile($results); - - if (!$isSafe) { - return $default; - } - } - - return $results; - } - - return $default; - } - - /** - * Method to decode a data array. - * - * @param array $data The data array to decode. - * - * @return array - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ - protected function decodeData(array $data) - { - $result = []; - - if (\is_array($data[0])) { - foreach ($data[0] as $k => $v) { - $result[$k] = $this->decodeData([$data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]]); - } - - return $result; - } - - return ['name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]]; - } - - /** - * Sets a value. - * - * @param string $name The name of the input property to set. - * @param mixed $value The value to assign to the input property. - * - * @return void - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Files instead - */ - public function set($name, $value) - { - } -} diff --git a/libraries/src/Input/Input.php b/libraries/src/Input/Input.php deleted file mode 100644 index e3f5544d32ae5..0000000000000 --- a/libraries/src/Input/Input.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\CMS\Input; - -use Joomla\CMS\Filter\InputFilter; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * Joomla! Input Base Class - * - * This is an abstracted input class used to manage retrieving data from the application environment. - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - * - * @property-read Input $get - * @property-read Input $post - * @property-read Input $request - * @property-read Input $server - * @property-read Input $env - * @property-read Files $files - * @property-read Cookie $cookie - * @property-read Json $json - */ -class Input extends \Joomla\Input\Input -{ - /** - * Container with allowed superglobals - * - * @var array - * @since 3.8.9 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - private static $allowedGlobals = ['REQUEST', 'GET', 'POST', 'FILES', 'SERVER', 'ENV']; - - /** - * Input objects - * - * @var Input[] - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - protected $inputs = []; - - /** - * Constructor. - * - * @param array $source Source data (Optional, default is $_REQUEST) - * @param array $options Array of configuration parameters (Optional) - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - public function __construct($source = null, array $options = []) - { - if (!isset($options['filter'])) { - $this->filter = InputFilter::getInstance(); - } - - parent::__construct($source, $options); - } - - /** - * Magic method to get an input object - * - * @param mixed $name Name of the input object to retrieve. - * - * @return \Joomla\Input\Input The request input object - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - public function __get($name) - { - if (isset($this->inputs[$name])) { - return $this->inputs[$name]; - } - - $className = '\\Joomla\\CMS\\Input\\' . ucfirst($name); - - if (class_exists($className)) { - $this->inputs[$name] = new $className(null, $this->options); - - return $this->inputs[$name]; - } - - $superGlobal = '_' . strtoupper($name); - - if (\in_array(strtoupper($name), self::$allowedGlobals, true) && isset($GLOBALS[$superGlobal])) { - $this->inputs[$name] = new Input($GLOBALS[$superGlobal], $this->options); - - return $this->inputs[$name]; - } - - // Try using the parent class - return parent::__get($name); - } - - /** - * Gets an array of values from the request. - * - * @param array $vars Associative array of keys and filter types to apply. - * If empty and datasource is null, all the input data will be returned - * but filtered using the filter given by the parameter defaultFilter in - * InputFilter::clean. - * @param mixed $datasource Array to retrieve data from, or null. - * @param string $defaultFilter Default filter used in InputFilter::clean if vars is empty and - * datasource is null. If 'unknown', the default case is used in - * InputFilter::clean. - * - * @return mixed The filtered input data. - * - * @since 1.7.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - public function getArray(array $vars = [], $datasource = null, $defaultFilter = 'unknown') - { - return $this->getArrayRecursive($vars, $datasource, $defaultFilter, false); - } - - /** - * Gets an array of values from the request. - * - * @param array $vars Associative array of keys and filter types to apply. - * If empty and datasource is null, all the input data will be returned - * but filtered using the filter given by the parameter defaultFilter in - * InputFilter::clean. - * @param mixed $datasource Array to retrieve data from, or null. - * @param string $defaultFilter Default filter used in InputFilter::clean if vars is empty and - * datasource is null. If 'unknown', the default case is used in - * InputFilter::clean. - * @param bool $recursion Flag to indicate a recursive function call. - * - * @return mixed The filtered input data. - * - * @since 3.4.2 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - protected function getArrayRecursive(array $vars = [], $datasource = null, $defaultFilter = 'unknown', $recursion = false) - { - if (empty($vars) && \is_null($datasource)) { - $vars = $this->data; - } else { - if (!$recursion) { - $defaultFilter = null; - } - } - - $results = []; - - foreach ($vars as $k => $v) { - if (\is_array($v)) { - if (\is_null($datasource)) { - $results[$k] = $this->getArrayRecursive($v, $this->get($k, null, 'array'), $defaultFilter, true); - } else { - $results[$k] = $this->getArrayRecursive($v, $datasource[$k], $defaultFilter, true); - } - } else { - $filter = $defaultFilter ?? $v; - - if (\is_null($datasource)) { - $results[$k] = $this->get($k, null, $filter); - } elseif (isset($datasource[$k])) { - $results[$k] = $this->filter->clean($datasource[$k], $filter); - } else { - $results[$k] = $this->filter->clean(null, $filter); - } - } - } - - return $results; - } - - /** - * Method to unserialize the input. - * - * @param string $input The serialized input. - * - * @return void - * - * @since 3.0.0 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Input instead - */ - public function unserialize($input) - { - // Unserialize the options, data, and inputs. - list($this->options, $this->data, $this->inputs) = unserialize($input); - - // Load the filter. - if (isset($this->options['filter'])) { - $this->filter = $this->options['filter']; - } else { - $this->filter = InputFilter::getInstance(); - } - } -} diff --git a/libraries/src/Input/Json.php b/libraries/src/Input/Json.php deleted file mode 100644 index fa3cdba64455c..0000000000000 --- a/libraries/src/Input/Json.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\CMS\Input; - -use Joomla\CMS\Filter\InputFilter; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * Joomla! Input JSON Class - * - * This class decodes a JSON string from the raw request data and makes it available via - * the standard JInput interface. - * - * @since 3.0.1 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Json instead - */ -class Json extends Input -{ - /** - * @var string The raw JSON string from the request. - * @since 3.0.1 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Json instead - */ - private $_raw; - - /** - * Constructor. - * - * @param array $source Source data (Optional, default is the raw HTTP input decoded from JSON) - * @param array $options Array of configuration parameters (Optional) - * - * @since 3.0.1 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Json instead - */ - public function __construct(array $source = null, array $options = []) - { - if (isset($options['filter'])) { - $this->filter = $options['filter']; - } else { - $this->filter = InputFilter::getInstance(); - } - - if (\is_null($source)) { - $this->_raw = file_get_contents('php://input'); - $this->data = json_decode($this->_raw, true); - - if (!\is_array($this->data)) { - $this->data = []; - } - } else { - $this->data = &$source; - } - - $this->options = $options; - } - - /** - * Gets the raw JSON string from the request. - * - * @return string The raw JSON string from the request. - * - * @since 3.0.1 - * - * @deprecated 4.3 will be removed in 6.0. - * Use Joomla\Input\Json instead - */ - public function getRaw() - { - return $this->_raw; - } -} diff --git a/libraries/src/Service/Provider/Application.php b/libraries/src/Service/Provider/Application.php index c3555a91c97d4..292c1c408d527 100644 --- a/libraries/src/Service/Provider/Application.php +++ b/libraries/src/Service/Provider/Application.php @@ -36,7 +36,6 @@ use Joomla\CMS\Console\TasksRunCommand; use Joomla\CMS\Console\TasksStateCommand; use Joomla\CMS\Console\UpdateCoreCommand; -use Joomla\CMS\Input\Input as CMSInput; use Joomla\CMS\Language\LanguageFactoryInterface; use Joomla\CMS\Menu\MenuFactoryInterface; use Joomla\CMS\User\UserFactoryInterface; @@ -49,6 +48,7 @@ use Joomla\DI\ServiceProviderInterface; use Joomla\Event\DispatcherInterface; use Joomla\Event\Priority; +use Joomla\Input\Input as CMSInput; use Joomla\Session\SessionEvents; use Joomla\Session\SessionInterface; use Psr\Log\LoggerInterface; diff --git a/libraries/src/Service/Provider/Input.php b/libraries/src/Service/Provider/Input.php index f1d2f82dd3f6f..15e4286db0f4d 100644 --- a/libraries/src/Service/Provider/Input.php +++ b/libraries/src/Service/Provider/Input.php @@ -9,9 +9,9 @@ namespace Joomla\CMS\Service\Provider; -use Joomla\CMS\Input\Input as CMSInput; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; +use Joomla\Input\Input as CMSInput; /** * Service provider for the the Joomla Input object. diff --git a/libraries/src/Service/Provider/Session.php b/libraries/src/Service/Provider/Session.php index df97bb95196e7..5cbac113b3535 100644 --- a/libraries/src/Service/Provider/Session.php +++ b/libraries/src/Service/Provider/Session.php @@ -13,7 +13,6 @@ use Joomla\CMS\Application\ConsoleApplication; use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Factory; -use Joomla\CMS\Input\Input as CMSInput; use Joomla\CMS\Installation\Application\InstallationApplication; use Joomla\CMS\Session\EventListener\MetadataManagerListener; use Joomla\CMS\Session\MetadataManager; @@ -26,6 +25,7 @@ use Joomla\DI\ServiceProviderInterface; use Joomla\Event\DispatcherInterface; use Joomla\Event\LazyServiceEventListener; +use Joomla\Input\Input as CMSInput; use Joomla\Registry\Registry; use Joomla\Session\HandlerInterface; use Joomla\Session\SessionEvents;