diff --git a/app/Config/App.php b/app/Config/App.php index ffe0c6c..2da765f 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -21,7 +21,7 @@ | environments. | */ - public $baseURL = 'http://localhost:8080'; + public $baseURL = 'http://localhost:8080/'; /* |-------------------------------------------------------------------------- diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index af0e201..6a673d3 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -50,9 +50,9 @@ * `]; */ $psr4 = [ - 'Config' => APPPATH . 'Config', - APP_NAMESPACE => APPPATH, // For custom namespace 'App' => APPPATH, // To ensure filters, etc still found, + APP_NAMESPACE => APPPATH, // For custom namespace + 'Config' => APPPATH . 'Config', ]; /** diff --git a/app/Config/Database.php b/app/Config/Database.php index f3fe66c..b31541a 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -62,9 +62,9 @@ 'hostname' => '127.0.0.1', 'username' => '', 'password' => '', - 'database' => '', - 'DBDriver' => '', - 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE. + 'database' => ':memory:', + 'DBDriver' => 'SQLite3', + 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS 'pConnect' => false, 'DBDebug' => (ENVIRONMENT !== 'production'), 'cacheOn' => false, diff --git a/app/Config/Email.php b/app/Config/Email.php index d580c53..d9ca142 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -1,7 +1,9 @@ WRITEPATH . 'logs/', - - /* - * The default filename extension for log files. The default 'php' allows for - * protecting the log files via basic scripting, when they are to be stored - * under a publicly accessible directory. + * The default filename extension for log files. + * An extension of 'php' allows for protecting the log files via basic + * scripting, when they are to be stored under a publicly accessible directory. * - * Note: Leaving it blank will default to 'php'. + * Note: Leaving it blank will default to 'log'. */ - 'fileExtension' => 'php', + 'fileExtension' => '', /* * The file system permissions to be applied on newly created log files. diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8e13664..4832736 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -1,22 +1,5 @@ defaultNamespace() - * - * Modifies the namespace that is added to a controller if it doesn't - * already have one. By default this is the global namespace (\). - * - * $routes->defaultController() - * - * Changes the name of the class used as a controller when the route - * points to a folder instead of a class. - * - * $routes->defaultMethod() - * - * Assigns the method inside the controller that is ran when the - * Router is unable to determine the appropriate method to run. - * - * $routes->setAutoRoute() - * - * Determines whether the Router will attempt to match URIs to - * Controllers when no specific route has been defined. If false, - * only routes that have been defined here will be available. */ $routes->setDefaultNamespace('App\Controllers'); $routes->setDefaultController('Home'); diff --git a/contributing.md b/contributing.md index 09dff38..abeea35 100644 --- a/contributing.md +++ b/contributing.md @@ -3,77 +3,90 @@ ## Contributions -We expect all contributions to conform to our style guide, be commented (inside the PHP source files), -be documented (in the user guide), and unit tested (in the test folder). +We expect all contributions to conform to our [style guide](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/styleguide.rst), be commented (inside the PHP source files), +be documented (in the [user guide](https://codeigniter4.github.io/userguide/)), and unit tested (in the [test folder](https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests)). There is a [Contributing to CodeIgniter](./contributing/README.rst) section in the repository which describes the contribution process; this page is an overview. +The [Open Source Guide](https://opensource.guide/) is a good first read for those new to contributing to open source! ## Issues -Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please check a few things first: +Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please make sure that: -1. There is not already an open Issue -2. The issue has already been fixed (check the develop branch, or look for closed Issues) -3. Is it something really obvious that you can fix yourself? +1. There is not already an open [Issue](https://github.com/codeigniter4/CodeIgniter4/issues) +2. The Issue has not already been fixed (check the develop branch or look for [closed Issues](https://github.com/codeigniter4/CodeIgniter4/issues?q=is%3Aissue+is%3Aclosed)) +3. It's not something really obvious that you can fix yourself -Reporting issues is helpful but an even [better approach](./contributing/workflow.rst) is to send a Pull Request, which is done by "Forking" the main repository and committing to your own copy. This will require you to use the version control system called Git. +Reporting Issues is helpful, but an even [better approach](./contributing/workflow.rst) is to send a [Pull Request](https://help.github.com/en/articles/creating-a-pull-request), which is done by [Forking](https://help.github.com/en/articles/fork-a-repo) the main repository and making a [Commit](https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project) to your own copy of the project. This will require you to use the version control system called [Git](https://git-scm.com/). ## Guidelines -Before we look into how, here are the guidelines. If your Pull Requests fail -to pass these guidelines it will be declined and you will need to re-submit +Before we look into how to contribute to CodeIgniter4, here are some guidelines. If your Pull Requests fail +to pass these guidelines, they will be declined, and you will need to re-submit when you’ve made the changes. This might sound a bit tough, but it is required -for us to maintain quality of the code-base. +for us to maintain quality of the codebase. ### PHP Style All code must meet the [Style Guide](./contributing/styleguide.rst). -This makes certain that all code is the same format as the existing code and means it will be as readable as possible. +This makes certain that all submitted code is of the same format as the existing code and ensures that the codebase will be as readable as possible. ### Documentation -If you change anything that requires a change to documentation then you will need to add it. New classes, methods, parameters, changing default values, etc are all things that will require a change to documentation. The change-log must also be updated for every change. Also PHPDoc blocks must be maintained. +If you change anything that requires a change to documentation, then you will need to add to the documentation. New classes, methods, parameters, changing default values, etc. are all changes that require a change to documentation. Also, the [changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html) must be updated for every change, and [PHPDoc](https://github.com/codeigniter4/CodeIgniter4/blob/develop/phpdoc.dist.xml) blocks must be maintained. ### Compatibility -CodeIgniter4 requires PHP 7.2. +CodeIgniter4 requires [PHP 7.2](https://php.net/releases/7_2_0.php). ### Branching -CodeIgniter4 uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all pull requests to be sent to the "develop" branch. This is -where the next planned version will be developed. The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security patch) can be applied to master to create a new version, without worrying about other features holding it up. For this reason all commits need to be made to "develop" and any sent to "master" will be closed automatically. If you have multiple changes to submit, please place all changes into their own branch on your fork. +CodeIgniter4 uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all +Pull Requests to be sent to the "develop" branch; this is where the next planned version will be developed. +The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g. an +emergency security patch) can be applied to the "master" branch to create a new version, without worrying +about other features holding it up. For this reason, all commits need to be made to the "develop" branch, +and any sent to the "master" branch will be closed automatically. If you have multiple changes to submit, +please place all changes into their own branch on your fork. -One thing at a time: A pull request should only contain one change. That does not mean only one commit, but one change - however many commits it took. The reason for this is that if you change X and Y but send a pull request for both at the same time, we might really want X but disagree with Y, meaning we cannot merge the request. Using the Git-Flow branching model you can create new branches for both of these features and send two requests. +**One thing at a time:** A pull request should only contain one change. That does not mean only one commit, +but one change - however many commits it took. The reason for this is that if you change X and Y, +but send a pull request for both at the same time, we might really want X but disagree with Y, +meaning we cannot merge the request. Using the Git-Flow branching model you can create new +branches for both of these features and send two requests. + +A reminder: **please use separate branches for each of your PRs** - it will make it easier for you to keep changes separate from +each other and from whatever else you are doing with your repository! ### Signing -You must [GPG-sign](./contributing/signing.rst) your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. This is *not* just a "signed-off-by" commit, but instead a digitally signed one. +You must [GPG-sign](./contributing/signing.rst) your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. This is *not* just a "signed-off-by" commit, but instead, a digitally signed one. ## How-to Guide The best way to contribute is to fork the CodeIgniter4 repository, and "clone" that to your development area. That sounds like some jargon, but "forking" on GitHub means "making a copy of that repo to your account" and "cloning" means "copying that code to your environment so you can work on it". -1. Set up Git (Windows, Mac & Linux) -2. Go to the CodeIgniter4 repo -3. Fork it (to your Github account) -4. Clone your CodeIgniter repo: git@github.com:\/CodeIgniter4.git -5. Create a new branch in your project for each set of changes you want to make. -6. Fix existing bugs on the Issue tracker after taking a look to see nobody else is working on them. -7. Commit the changed files in your contribution branch -8. Push your contribution branch to your fork -9. Send a pull request [http://help.github.com/send-pull-requests/](http://help.github.com/send-pull-requests/) +1. Set up Git ([Windows](https://git-scm.com/download/win), [Mac](https://git-scm.com/download/mac), & [Linux](https://git-scm.com/download/linux)). +2. Go to the [CodeIgniter4 repository](https://github.com/codeigniter4/CodeIgniter4). +3. [Fork](https://help.github.com/en/articles/fork-a-repo) it (to your Github account). +4. [Clone](https://help.github.com/en/articles/cloning-a-repository) your CodeIgniter repository: `git@github.com:\/CodeIgniter4.git` +5. Create a new [branch](https://help.github.com/en/articles/about-branches) in your project for each set of changes you want to make. +6. Fix existing bugs on the [Issue tracker](https://github.com/codeigniter4/CodeIgniter4/issues) after confirming that no one else is working on them. +7. [Commit](https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project) the changed files in your contribution branch. +8. [Push](https://help.github.com/en/articles/pushing-to-a-remote) your contribution branch to your fork. +9. Send a [pull request](http://help.github.com/send-pull-requests/). -The codebase maintainers will now be alerted about the change and at least one of the team will respond. If your change fails to meet the guidelines it will be bounced, or feedback will be provided to help you improve it. +The codebase maintainers will now be alerted to the submission and someone from the team will respond. If your change fails to meet the guidelines, it will be rejected or feedback will be provided to help you improve it. -Once the maintainer handling your pull request is happy with it they will merge it into develop and your patch will be part of the next release. +Once the maintainer handling your pull request is satisfied with it they will approve the pull request and merge it into the "develop" branch; your patch will now be part of the next release! ### Keeping your fork up-to-date -Unlike systems like Subversion, Git can have multiple remotes. A remote is the name for a URL of a Git repository. By default your fork will have a remote named "origin" which points to your fork, but you can add another remote named "codeigniter" which points to `git://github.com/codeigniter4/CodeIgniter4.git`. This is a read-only remote but you can pull from this develop branch to update your own. +Unlike systems like Subversion, Git can have multiple remotes. A remote is the name for the URL of a Git repository. By default, your fork will have a remote named "origin", which points to your fork, but you can add another remote named "codeigniter", which points to `git://github.com/codeigniter4/CodeIgniter4.git`. This is a read-only remote, but you can pull from this develop branch to update your own. -If you are using command-line you can do the following: +If you are using the command-line, you can do the following to update your fork to the latest changes: 1. `git remote add codeigniter git://github.com/codeigniter4/CodeIgniter4.git` 2. `git pull codeigniter develop` 3. `git push origin develop` -Now your fork is up to date. This should be done regularly, or before you send a pull request at least. +Your fork is now up to date. This should be done regularly and, at the least, before you submit a pull request. diff --git a/license.txt b/license.txt index 6dea8d0..2fb1bdd 100644 --- a/license.txt +++ b/license.txt @@ -1,7 +1,7 @@ The MIT License (MIT) Copyright (c) 2014-2019 British Columbia Institute of Technology -Copyright (c) 2019 CodeIgniter Foundation +Copyright (c) 2019-2020 CodeIgniter Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/public/.htaccess b/public/.htaccess index 8af50c9..699e1c1 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -17,7 +17,8 @@ # RewriteBase / # Redirect Trailing Slashes... - RewriteRule ^(.*)/$ /$1 [L,R=301] + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] # Rewrite "www.example.com -> example.com" RewriteCond %{HTTPS} !=on diff --git a/system/API/ResponseTrait.php b/system/API/ResponseTrait.php index e98ef0f..f16b284 100644 --- a/system/API/ResponseTrait.php +++ b/system/API/ResponseTrait.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index dbd1c5d..4663107 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 7d3818b..ad4a812 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -287,10 +287,23 @@ { $namespaces = []; + // Save system for last + $system = null; + foreach ($this->autoloader->getNamespace() as $prefix => $paths) { foreach ($paths as $path) { + if ($prefix === 'CodeIgniter') + { + $system = [ + 'prefix' => $prefix, + 'path' => rtrim($path, '\\/') . DIRECTORY_SEPARATOR, + ]; + + continue; + } + $namespaces[] = [ 'prefix' => $prefix, 'path' => rtrim($path, '\\/') . DIRECTORY_SEPARATOR, @@ -298,6 +311,8 @@ } } + $namespaces[] = $system; + return $namespaces; } diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index 158413e..7f81e9e 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index ea17ddc..e60036c 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php index 50704ed..b1e6103 100644 --- a/system/CLI/CommandRunner.php +++ b/system/CLI/CommandRunner.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -40,7 +40,7 @@ namespace CodeIgniter\CLI; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\Controller; /** diff --git a/system/CLI/Console.php b/system/CLI/Console.php index 1affaf8..cf50384 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/CacheFactory.php b/system/Cache/CacheFactory.php index dc85548..ed0741a 100644 --- a/system/Cache/CacheFactory.php +++ b/system/Cache/CacheFactory.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index fc8fb90..d3f28d8 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/DummyHandler.php b/system/Cache/Handlers/DummyHandler.php index a60ce01..c012f0d 100644 --- a/system/Cache/Handlers/DummyHandler.php +++ b/system/Cache/Handlers/DummyHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php index da05026..1d68d02 100644 --- a/system/Cache/Handlers/FileHandler.php +++ b/system/Cache/Handlers/FileHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index 6076da6..0c248a0 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php index 5749565..255a997 100644 --- a/system/Cache/Handlers/PredisHandler.php +++ b/system/Cache/Handlers/PredisHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index 17c8b13..f24b0eb 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Cache/Handlers/WincacheHandler.php b/system/Cache/Handlers/WincacheHandler.php index a49626f..305333d 100644 --- a/system/Cache/Handlers/WincacheHandler.php +++ b/system/Cache/Handlers/WincacheHandler.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index ae6fe77..b292bfb 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -66,7 +66,7 @@ /** * The current version of CodeIgniter Framework */ - const CI_VERSION = '4.0.0-rc.3'; + const CI_VERSION = '4.0.0-rc.4'; /** * App startup time. @@ -252,7 +252,7 @@ // If the route is a 'redirect' route, it throws // the exception with the $to as the message - $this->response->redirect($e->getMessage(), 'auto', $e->getCode()); + $this->response->redirect(base_url($e->getMessage()), 'auto', $e->getCode()); $this->sendResponse(); $this->callExit(EXIT_SUCCESS); @@ -373,7 +373,7 @@ // Save our current URI as the previous URI in the session // for safer, more accurate use with `previous_url()` helper function. - $this->storePreviousURL($this->request->uri ?? $uri); + $this->storePreviousURL((string)current_url(true)); unset($uri); @@ -883,7 +883,8 @@ $this->runController($controller); } - $this->gatherOutput(); + $cacheConfig = new Cache(); + $this->gatherOutput($cacheConfig); $this->sendResponse(); return; diff --git a/system/Commands/Database/CreateMigration.php b/system/Commands/Database/CreateMigration.php index db188fc..19d87a4 100644 --- a/system/Commands/Database/CreateMigration.php +++ b/system/Commands/Database/CreateMigration.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/Migrate.php b/system/Commands/Database/Migrate.php index 6dd05b5..e419b75 100644 --- a/system/Commands/Database/Migrate.php +++ b/system/Commands/Database/Migrate.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/MigrateRefresh.php b/system/Commands/Database/MigrateRefresh.php index 5ea788b..e0ec669 100644 --- a/system/Commands/Database/MigrateRefresh.php +++ b/system/Commands/Database/MigrateRefresh.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/MigrateRollback.php b/system/Commands/Database/MigrateRollback.php index 37a2162..ba25989 100644 --- a/system/Commands/Database/MigrateRollback.php +++ b/system/Commands/Database/MigrateRollback.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php index 7355533..8e71436 100644 --- a/system/Commands/Database/MigrateStatus.php +++ b/system/Commands/Database/MigrateStatus.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Database/Seed.php b/system/Commands/Database/Seed.php index 32a57dd..ee09e0a 100644 --- a/system/Commands/Database/Seed.php +++ b/system/Commands/Database/Seed.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -98,8 +98,7 @@ protected $options = []; /** - * Runs all of the migrations in reverse order, until they have - * all been un-applied. + * Passes to Seeder to populate the database. * * @param array $params */ diff --git a/system/Commands/Help.php b/system/Commands/Help.php index 3672e6c..5769685 100644 --- a/system/Commands/Help.php +++ b/system/Commands/Help.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php index e413aec..bae8e73 100644 --- a/system/Commands/ListCommands.php +++ b/system/Commands/ListCommands.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Server/Serve.php b/system/Commands/Server/Serve.php index 3abae11..efca3cf 100644 --- a/system/Commands/Server/Serve.php +++ b/system/Commands/Server/Serve.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Sessions/CreateMigration.php b/system/Commands/Sessions/CreateMigration.php index d030b67..15c7476 100644 --- a/system/Commands/Sessions/CreateMigration.php +++ b/system/Commands/Sessions/CreateMigration.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php index 2079a34..9b91e8e 100644 --- a/system/Commands/Utilities/Namespaces.php +++ b/system/Commands/Utilities/Namespaces.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index d516073..3e16591 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Common.php b/system/Common.php index d4ecc34..e661703 100644 --- a/system/Common.php +++ b/system/Common.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -48,7 +48,7 @@ use Config\Logger; use Config\Services; use Tests\Support\Log\TestLogger; -use Zend\Escaper\Escaper; +use Laminas\Escaper\Escaper; /** * Common Functions diff --git a/system/ComposerScripts.php b/system/ComposerScripts.php index 6cf41f9..9666d00 100644 --- a/system/ComposerScripts.php +++ b/system/ComposerScripts.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -150,16 +150,16 @@ } /** - * Moves the Zend Escaper files into our base repo so that it's + * Moves the Laminas Escaper files into our base repo so that it's * available for packaged releases where the users don't user Composer. * * @throws \ReflectionException */ public static function moveEscaper() { - if (class_exists('\\Zend\\Escaper\\Escaper') && is_file(static::getClassFilePath('\\Zend\\Escaper\\Escaper'))) + if (class_exists('\\Laminas\\Escaper\\Escaper') && is_file(static::getClassFilePath('\\Laminas\\Escaper\\Escaper'))) { - $base = basename(__DIR__) . '/' . static::$basePath . 'ZendEscaper'; + $base = basename(__DIR__) . '/' . static::$basePath . 'Escaper'; foreach ([$base, $base . '/Exception'] as $path) { @@ -170,10 +170,10 @@ } $files = [ - static::getClassFilePath('\\Zend\\Escaper\\Exception\\ExceptionInterface') => $base . '/Exception/ExceptionInterface.php', - static::getClassFilePath('\\Zend\\Escaper\\Exception\\InvalidArgumentException') => $base . '/Exception/InvalidArgumentException.php', - static::getClassFilePath('\\Zend\\Escaper\\Exception\\RuntimeException') => $base . '/Exception/RuntimeException.php', - static::getClassFilePath('\\Zend\\Escaper\\Escaper') => $base . '/Escaper.php', + static::getClassFilePath('\\Laminas\\Escaper\\Exception\\ExceptionInterface') => $base . '/Exception/ExceptionInterface.php', + static::getClassFilePath('\\Laminas\\Escaper\\Exception\\InvalidArgumentException') => $base . '/Exception/InvalidArgumentException.php', + static::getClassFilePath('\\Laminas\\Escaper\\Exception\\RuntimeException') => $base . '/Exception/RuntimeException.php', + static::getClassFilePath('\\Laminas\\Escaper\\Escaper') => $base . '/Escaper.php', ]; foreach ($files as $source => $dest) diff --git a/system/Config/AutoloadConfig.php b/system/Config/AutoloadConfig.php index 57dd92e..ea4e0fd 100644 --- a/system/Config/AutoloadConfig.php +++ b/system/Config/AutoloadConfig.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -124,7 +124,7 @@ 'Psr\Log\LoggerTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php', 'Psr\Log\LogLevel' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php', 'Psr\Log\NullLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php', - 'Zend\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/ZendEscaper/Escaper.php', + 'Laminas\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/Escaper/Escaper.php', ]; if (isset($_SERVER['CI_ENVIRONMENT']) && $_SERVER['CI_ENVIRONMENT'] === 'testing') diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index 2d5bbf1..9a0100f 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 67f6cb6..a3eeaed 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Config.php b/system/Config/Config.php index 6098037..1e425d3 100644 --- a/system/Config/Config.php +++ b/system/Config/Config.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/DotEnv.php b/system/Config/DotEnv.php index 1828456..cbf64e7 100644 --- a/system/Config/DotEnv.php +++ b/system/Config/DotEnv.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/ForeignCharacters.php b/system/Config/ForeignCharacters.php index 220ae10..11d0f6c 100644 --- a/system/Config/ForeignCharacters.php +++ b/system/Config/ForeignCharacters.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Routes.php b/system/Config/Routes.php index 40cc49c..c891ec3 100644 --- a/system/Config/Routes.php +++ b/system/Config/Routes.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Config/Services.php b/system/Config/Services.php index 7eeaecb..6f166a6 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -208,7 +208,6 @@ $config = new \Config\Email(); } $email = new \CodeIgniter\Email\Email($config); - $email->setLogger(static::logger(true)); return $email; } @@ -436,7 +435,7 @@ //-------------------------------------------------------------------- /** - * Return the appropriate igration runner. + * Return the appropriate Migration runner. * * @param \CodeIgniter\Config\BaseConfig $config * @param \CodeIgniter\Database\ConnectionInterface $db @@ -605,7 +604,7 @@ return new IncomingRequest( $config, - new URI(), + static::uri(), 'php://input', new UserAgent() ); diff --git a/system/Config/View.php b/system/Config/View.php index 9e314a4..e9cafa6 100644 --- a/system/Config/View.php +++ b/system/Config/View.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Controller.php b/system/Controller.php index 390d0de..172104e 100644 --- a/system/Controller.php +++ b/system/Controller.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Validation\Validation; diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 2fbfd96..e7ee3a1 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -169,6 +169,15 @@ protected $QBWhereGroupCount = 0; /** + * Ignore data that cause certain + * exceptions, for example in case of + * duplicate keys. + * + * @var boolean + */ + protected $QBIgnore = false; + + /** * A reference to the database connection. * * @var BaseConnection @@ -221,6 +230,14 @@ protected $canLimitWhereUpdates = true; /** + * Specifies which sql statements + * support the ignore option. + * + * @var array + */ + protected $supportedIgnoreStatements = []; + + /** * Builder testing mode status. * * @var boolean @@ -292,6 +309,25 @@ //-------------------------------------------------------------------- /** + * Ignore + * + * Set ignore Flag for next insert, + * update or delete query. + * + * @param boolean $ignore + * + * @return BaseBuilder + */ + public function ignore(bool $ignore = true) + { + $this->QBIgnore = $ignore; + + return $this; + } + + //-------------------------------------------------------------------- + + /** * Select * * Generates the SELECT portion of the query @@ -2037,7 +2073,7 @@ */ protected function _insertBatch(string $table, array $keys, array $values): string { - return 'INSERT INTO ' . $table . ' (' . implode(', ', $keys) . ') VALUES ' . implode(', ', $values); + return 'INSERT ' . $this->compileIgnore('insert') . 'INTO ' . $table . ' (' . implode(', ', $keys) . ') VALUES ' . implode(', ', $values); } //-------------------------------------------------------------------- @@ -2106,6 +2142,8 @@ * * @param boolean $reset TRUE: reset QB values; FALSE: leave QB values alone * + * @throws DatabaseException + * * @return string */ public function getCompiledInsert(bool $reset = true): string @@ -2139,6 +2177,8 @@ * @param array $set An associative array of insert values * @param boolean $escape Whether to escape values and identifiers * + * @throws DatabaseException + * * @return BaseResult|Query|false */ public function insert(array $set = null, bool $escape = null) @@ -2216,7 +2256,7 @@ */ protected function _insert(string $table, array $keys, array $unescapedKeys): string { - return 'INSERT INTO ' . $table . ' (' . implode(', ', $keys) . ') VALUES (' . implode(', ', $unescapedKeys) . ')'; + return 'INSERT ' . $this->compileIgnore('insert') . 'INTO ' . $table . ' (' . implode(', ', $keys) . ') VALUES (' . implode(', ', $unescapedKeys) . ')'; } //-------------------------------------------------------------------- @@ -2330,6 +2370,8 @@ * @param mixed $where * @param integer $limit * + * @throws DatabaseException + * * @return boolean TRUE on success, FALSE on failure */ public function update(array $set = null, $where = null, int $limit = null): bool @@ -2393,14 +2435,14 @@ */ protected function _update(string $table, array $values): string { - $valstr = []; + $valStr = []; foreach ($values as $key => $val) { - $valstr[] = $key . ' = ' . $val; + $valStr[] = $key . ' = ' . $val; } - return 'UPDATE ' . $table . ' SET ' . implode(', ', $valstr) + return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . implode(', ', $valStr) . $this->compileWhereHaving('QBWhere') . $this->compileOrderBy() . ($this->QBLimit ? $this->_limit(' ') : ''); @@ -2530,6 +2572,7 @@ { $ids = []; $final = []; + foreach ($values as $key => $val) { $ids[] = $val[$index]; @@ -2553,7 +2596,7 @@ $this->where($index . ' IN(' . implode(',', $ids) . ')', null, false); - return 'UPDATE ' . $table . ' SET ' . substr($cases, 0, -2) . $this->compileWhereHaving('QBWhere'); + return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . substr($cases, 0, -2) . $this->compileWhereHaving('QBWhere'); } //-------------------------------------------------------------------- @@ -2806,7 +2849,7 @@ */ protected function _delete(string $table): string { - return 'DELETE FROM ' . $table . $this->compileWhereHaving('QBWhere') + return 'DELETE ' . $this->compileIgnore('delete') . 'FROM ' . $table . $this->compileWhereHaving('QBWhere') . ($this->QBLimit ? ' LIMIT ' . $this->QBLimit : ''); } @@ -2923,6 +2966,32 @@ //-------------------------------------------------------------------- /** + * Compile Ignore Statement + * + * Checks if the ignore option is supported by + * the Database Driver for the specific statement. + * + * @param string $statement + * + * @return string + */ + protected function compileIgnore(string $statement) + { + $sql = ''; + + if ($this->QBIgnore && + isset($this->supportedIgnoreStatements[$statement]) + ) + { + $sql = trim($this->supportedIgnoreStatements[$statement]) . ' '; + } + + return $sql; + } + + //-------------------------------------------------------------------- + + /** * Compile WHERE, HAVING statements * * Escapes identifiers in WHERE and HAVING statements at execution time. @@ -3242,6 +3311,7 @@ 'QBOrderBy' => [], 'QBKeys' => [], 'QBLimit' => false, + 'QBIgnore' => false, ]); } diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 038119a..56d71fb 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -1054,9 +1054,9 @@ * * Used by the Debug Toolbar's timeline. * - * @return float + * @return float|null */ - public function getConnectStart(): float + public function getConnectStart(): ?float { return $this->connectTime; } diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index d39239f..247d68c 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index d316c07..b9d586a 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/BaseUtils.php b/system/Database/BaseUtils.php index 0723562..a2ba2b0 100644 --- a/system/Database/BaseUtils.php +++ b/system/Database/BaseUtils.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Config.php b/system/Database/Config.php index 2c079df..89dd495 100644 --- a/system/Database/Config.php +++ b/system/Database/Config.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 26c38bd..dffa5f3 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Database.php b/system/Database/Database.php index f27d3db..a8d26b1 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Exceptions/DatabaseException.php b/system/Database/Exceptions/DatabaseException.php index 96738c0..cb411cf 100644 --- a/system/Database/Exceptions/DatabaseException.php +++ b/system/Database/Exceptions/DatabaseException.php @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Forge.php b/system/Database/Forge.php index c235fa1..ebe31fd 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -113,10 +113,10 @@ protected $createDatabaseIfStr = null; /** - * CHECK DATABASE EXIST statement - * - * @var string - */ + * CHECK DATABASE EXIST statement + * + * @var string + */ protected $checkDatabaseExistStr = null; /** @@ -214,7 +214,7 @@ /** * Create database * - * @param string $dbName + * @param string $dbName * @param boolean $ifNotExists Whether to add IF NOT EXISTS condition * * @return boolean @@ -230,7 +230,7 @@ } $ifNotExists = false; } - + if ($this->createDatabaseStr === false) { if ($this->db->DBDebug) diff --git a/system/Database/Migration.php b/system/Database/Migration.php index 7d53c23..3af3229 100644 --- a/system/Database/Migration.php +++ b/system/Database/Migration.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 4407363..6d4f0e2 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -305,6 +305,9 @@ throw new \RuntimeException($message); } + // Save the namespace to restore it after loading migrations + $tmpNamespace = $this->namespace; + // Get all migrations $this->namespace = null; $allMigrations = $this->findMigrations(); @@ -366,6 +369,9 @@ } } + // Restore the namespace + $this->namespace = $tmpNamespace; + return true; } @@ -682,7 +688,7 @@ */ public function getObjectUid($object): string { - return $object->version . $object->class; + return preg_replace('/[^0-9]/', '', $object->version) . $object->class; } //-------------------------------------------------------------------- @@ -945,8 +951,8 @@ $forge->addField([ 'id' => [ - 'type' => 'INTEGER', - 'constraint' => 255, + 'type' => 'BIGINT', + 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true, ], diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php index 908f571..d2eb6e6 100644 --- a/system/Database/MySQLi/Builder.php +++ b/system/Database/MySQLi/Builder.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -55,6 +55,18 @@ protected $escapeChar = '`'; /** + * Specifies which sql statements + * support the ignore option. + * + * @var array + */ + protected $supportedIgnoreStatements = [ + 'update' => 'IGNORE', + 'insert' => 'IGNORE', + 'delete' => 'IGNORE', + ]; + + /** * FROM tables * * Groups tables in FROM clauses if needed, so there is no confusion @@ -73,5 +85,4 @@ return implode(', ', $this->QBFrom); } - } diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 70c3f9c..95cd66d 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -491,6 +491,7 @@ sscanf($query[$i]->Type, '%[a-z](%d)', $retVal[$i]->type, $retVal[$i]->max_length); + $retVal[$i]->nullable = $query[$i]->Null === 'YES'; $retVal[$i]->default = $query[$i]->Default; $retVal[$i]->primary_key = (int)($query[$i]->Key === 'PRI'); } diff --git a/system/Database/MySQLi/Forge.php b/system/Database/MySQLi/Forge.php index c17f1ac..7e7e0a2 100644 --- a/system/Database/MySQLi/Forge.php +++ b/system/Database/MySQLi/Forge.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MySQLi/PreparedQuery.php b/system/Database/MySQLi/PreparedQuery.php index ef02018..35d87b1 100644 --- a/system/Database/MySQLi/PreparedQuery.php +++ b/system/Database/MySQLi/PreparedQuery.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MySQLi/Result.php b/system/Database/MySQLi/Result.php index 65cb23f..32f5f90 100644 --- a/system/Database/MySQLi/Result.php +++ b/system/Database/MySQLi/Result.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/MySQLi/Utils.php b/system/Database/MySQLi/Utils.php index 799a03d..e5056d1 100644 --- a/system/Database/MySQLi/Utils.php +++ b/system/Database/MySQLi/Utils.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index a7424b0..bf20a3d 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -40,6 +40,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\Exceptions\DatabaseException; +use http\Encoding\Stream\Inflate; /** * Builder for Postgre @@ -56,6 +57,40 @@ 'RANDOM()', ]; + /** + * Specifies which sql statements + * support the ignore option. + * + * @var array + */ + protected $supportedIgnoreStatements = [ + 'insert' => 'ON CONFLICT DO NOTHING', + ]; + + //-------------------------------------------------------------------- + + /** + * Compile Ignore Statement + * + * Checks if the ignore option is supported by + * the Database Driver for the specific statement. + * + * @param string $statement + * + * @return string + */ + protected function compileIgnore(string $statement) + { + $sql = parent::compileIgnore($statement); + + if (! empty($sql)) + { + $sql = ' ' . trim($sql); + } + + return $sql; + } + //-------------------------------------------------------------------- /** @@ -98,6 +133,8 @@ * @param string $column * @param integer $value * + * @throws DatabaseException + * * @return mixed */ public function increment(string $column, int $value = 1) @@ -117,6 +154,8 @@ * @param string $column * @param integer $value * + * @throws DatabaseException + * * @return mixed */ public function decrement(string $column, int $value = 1) diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 4dac1ec..b239232 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -473,7 +473,7 @@ { $v = pg_version($this->connID); // 'server' key is only available since PostgreSQL 7.4 - $v = $v['server'] ?? 0; + $v = explode(' ', $v['server'])[0] ?? 0; $table = func_num_args() > 0 ? func_get_arg(0) : null; $column = func_num_args() > 1 ? func_get_arg(1) : null; diff --git a/system/Database/Postgre/Forge.php b/system/Database/Postgre/Forge.php index d0ad4f1..c474459 100644 --- a/system/Database/Postgre/Forge.php +++ b/system/Database/Postgre/Forge.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -46,12 +46,12 @@ { /** - * CHECK DATABASE EXIST statement - * - * @var string - */ + * CHECK DATABASE EXIST statement + * + * @var string + */ protected $checkDatabaseExistStr = 'SELECT 1 FROM pg_database WHERE datname = ?'; - + /** * DROP CONSTRAINT statement * @@ -82,7 +82,7 @@ * @var string */ protected $_null = 'NULL'; - + //-------------------------------------------------------------------- /** diff --git a/system/Database/Postgre/PreparedQuery.php b/system/Database/Postgre/PreparedQuery.php index d1598cc..7b3bff3 100644 --- a/system/Database/Postgre/PreparedQuery.php +++ b/system/Database/Postgre/PreparedQuery.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Result.php b/system/Database/Postgre/Result.php index a33f9f0..a58a14e 100644 --- a/system/Database/Postgre/Result.php +++ b/system/Database/Postgre/Result.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Postgre/Utils.php b/system/Database/Postgre/Utils.php index 85965a0..dd45de1 100644 --- a/system/Database/Postgre/Utils.php +++ b/system/Database/Postgre/Utils.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/PreparedQueryInterface.php b/system/Database/PreparedQueryInterface.php index 1ddbad0..8bd9476 100644 --- a/system/Database/PreparedQueryInterface.php +++ b/system/Database/PreparedQueryInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Query.php b/system/Database/Query.php index e1af64f..301185b 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/QueryInterface.php b/system/Database/QueryInterface.php index 423ac9f..4a2781e 100644 --- a/system/Database/QueryInterface.php +++ b/system/Database/QueryInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php index d8413b2..10105ff 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Builder.php b/system/Database/SQLite3/Builder.php index 911b9fe..b302f56 100644 --- a/system/Database/SQLite3/Builder.php +++ b/system/Database/SQLite3/Builder.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -70,6 +70,13 @@ */ protected $canLimitWhereUpdates = false; + /** + * @var array + */ + protected $supportedIgnoreStatements = [ + 'insert' => 'OR IGNORE', + ]; + //-------------------------------------------------------------------- /** @@ -106,6 +113,4 @@ return 'DELETE FROM ' . $table; } - //-------------------------------------------------------------------- - } diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 0ce1dac..ae83cfc 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Forge.php b/system/Database/SQLite3/Forge.php index 877c78e..338c6e4 100644 --- a/system/Database/SQLite3/Forge.php +++ b/system/Database/SQLite3/Forge.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -85,7 +85,7 @@ /** * Create database * - * @param string $dbName + * @param string $dbName * @param boolean $ifNotExists Whether to add IF NOT EXISTS condition * * @return boolean diff --git a/system/Database/SQLite3/PreparedQuery.php b/system/Database/SQLite3/PreparedQuery.php index 8f73385..fbd6fea 100644 --- a/system/Database/SQLite3/PreparedQuery.php +++ b/system/Database/SQLite3/PreparedQuery.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php index 3d8c53a..fac0725 100644 --- a/system/Database/SQLite3/Result.php +++ b/system/Database/SQLite3/Result.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Table.php b/system/Database/SQLite3/Table.php index a15f9a0..46264da 100644 --- a/system/Database/SQLite3/Table.php +++ b/system/Database/SQLite3/Table.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/SQLite3/Utils.php b/system/Database/SQLite3/Utils.php index f7cb337..72f8d4b 100644 --- a/system/Database/SQLite3/Utils.php +++ b/system/Database/SQLite3/Utils.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Database/Seeder.php b/system/Database/Seeder.php index 023cb4e..682b7ce 100644 --- a/system/Database/Seeder.php +++ b/system/Database/Seeder.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -168,6 +168,7 @@ $seeder = new $class($this->config); } + $seeder->setSilent($this->silent); $seeder->run(); unset($seeder); diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index a3ed7bf..7cc3043 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Iterator.php b/system/Debug/Iterator.php index 8f97807..c9101df 100644 --- a/system/Debug/Iterator.php +++ b/system/Debug/Iterator.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Timer.php b/system/Debug/Timer.php index 1d6438e..b12b52d 100644 --- a/system/Debug/Timer.php +++ b/system/Debug/Timer.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 4e218bc..9642ce0 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -136,7 +136,7 @@ { foreach ($items as $key => $value) { - $varData[esc($key)] = is_string($value) ? esc($value) : print_r($value, true); + $varData[esc($key)] = is_string($value) ? esc($value) : '
' . esc(print_r($value, true)) . '
'; } } @@ -153,18 +153,18 @@ $value = 'binary data'; } - $data['vars']['session'][esc($key)] = is_string($value) ? esc($value) : print_r($value, true); + $data['vars']['session'][esc($key)] = is_string($value) ? esc($value) : '
' . esc(print_r($value, true)) . '
'; } } foreach ($request->getGet() as $name => $value) { - $data['vars']['get'][esc($name)] = is_array($value) ? esc(print_r($value, true)) : esc($value); + $data['vars']['get'][esc($name)] = is_array($value) ? '
' . esc(print_r($value, true)) . '
' : esc($value); } foreach ($request->getPost() as $name => $value) { - $data['vars']['post'][esc($name)] = is_array($value) ? esc(print_r($value, true)) : esc($value); + $data['vars']['post'][esc($name)] = is_array($value) ? '
' . esc(print_r($value, true)) . '
' : esc($value); } foreach ($request->getHeaders() as $header => $value) @@ -375,7 +375,7 @@ // for this response if ($request->isAJAX() || strpos($format, 'html') === false) { - $response->setHeader('Debugbar-Time', $time) + $response->setHeader('Debugbar-Time', "$time") ->setHeader('Debugbar-Link', site_url("?debugbar_time={$time}")) ->getBody(); @@ -390,10 +390,10 @@ . '' . PHP_EOL; - if (strpos($response->getBody(), '') !== false) + if (strpos($response->getBody(), '') !== false) { $response->setBody( - str_replace('', $script . '', $response->getBody()) + str_replace('', $script . '', $response->getBody()) ); return; diff --git a/system/Debug/Toolbar/Collectors/BaseCollector.php b/system/Debug/Toolbar/Collectors/BaseCollector.php index 6fe76f9..dade0ab 100644 --- a/system/Debug/Toolbar/Collectors/BaseCollector.php +++ b/system/Debug/Toolbar/Collectors/BaseCollector.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Config.php b/system/Debug/Toolbar/Collectors/Config.php index f6839b4..1ae809c 100644 --- a/system/Debug/Toolbar/Collectors/Config.php +++ b/system/Debug/Toolbar/Collectors/Config.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 5b03d05..00aa740 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -175,6 +175,8 @@ 'WHERE', 'AND', 'LEFT JOIN', + 'RIGHT JOIN', + 'JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php index c574507..285d87d 100644 --- a/system/Debug/Toolbar/Collectors/Events.php +++ b/system/Debug/Toolbar/Collectors/Events.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\View\RendererInterface; /** @@ -94,7 +94,7 @@ */ public function __construct() { - $this->viewer = Services::renderer(null, true); + $this->viewer = Services::renderer(); } //-------------------------------------------------------------------- diff --git a/system/Debug/Toolbar/Collectors/Files.php b/system/Debug/Toolbar/Collectors/Files.php index 78c8b51..36b0132 100644 --- a/system/Debug/Toolbar/Collectors/Files.php +++ b/system/Debug/Toolbar/Collectors/Files.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/History.php b/system/Debug/Toolbar/Collectors/History.php index 90152f2..3112e07 100644 --- a/system/Debug/Toolbar/Collectors/History.php +++ b/system/Debug/Toolbar/Collectors/History.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php index b310b60..ed279c7 100644 --- a/system/Debug/Toolbar/Collectors/Logs.php +++ b/system/Debug/Toolbar/Collectors/Logs.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Loags collector diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php index 4891a15..2a80c55 100644 --- a/system/Debug/Toolbar/Collectors/Routes.php +++ b/system/Debug/Toolbar/Collectors/Routes.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Routes collector diff --git a/system/Debug/Toolbar/Collectors/Timers.php b/system/Debug/Toolbar/Collectors/Timers.php index ea5f5e3..d6168c6 100644 --- a/system/Debug/Toolbar/Collectors/Timers.php +++ b/system/Debug/Toolbar/Collectors/Timers.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Timers collector diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index 1f92507..8bcec56 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\View\RendererInterface; /** diff --git a/system/Debug/Toolbar/Views/toolbar.css b/system/Debug/Toolbar/Views/toolbar.css index 826c20c..f53b8fe 100644 --- a/system/Debug/Toolbar/Views/toolbar.css +++ b/system/Debug/Toolbar/Views/toolbar.css @@ -37,6 +37,10 @@ z-index: 10000; } +#debug-bar pre { + line-height: normal; +} + #debug-bar h1, #debug-bar h2, #debug-bar h3 { diff --git a/system/Debug/Toolbar/Views/toolbarloader.js.php b/system/Debug/Toolbar/Views/toolbarloader.js.php index 236ea01..4ecdeeb 100644 --- a/system/Debug/Toolbar/Views/toolbarloader.js.php +++ b/system/Debug/Toolbar/Views/toolbarloader.js.php @@ -56,7 +56,7 @@ } }; - xhttp.open("GET", url + "/?debugbar_time=" + time, true); + xhttp.open("GET", url + "?debugbar_time=" + time, true); xhttp.send(); } diff --git a/system/Email/Email.php b/system/Email/Email.php index 42d4b22..ee0e014 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014 - 2019, British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ namespace CodeIgniter\Email; use Config\Mimes; -use Psr\Log\LoggerAwareTrait; /** * CodeIgniter Email Class @@ -55,7 +54,6 @@ */ class Email { - use LoggerAwareTrait; /** * @var string */ @@ -355,12 +353,6 @@ * @var boolean */ protected static $func_overload; - /** - * Logger instance to record error messages and awarnings. - * - * @var \PSR\Log\LoggerInterface - */ - protected $logger; //-------------------------------------------------------------------- /** * Constructor - Sets Email Preferences @@ -373,7 +365,6 @@ { $this->initialize($config); isset(static::$func_overload) || static::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload')); - log_message('info', 'Email Class Initialized'); } //-------------------------------------------------------------------- /** @@ -1498,7 +1489,7 @@ $output = '=?' . $this->charset . '?Q?'; for ($i = 0, $length = static::strlen($output); $i < $chars; $i ++) { - $chr = ($this->charset === 'UTF-8' && ICONV_ENABLED === true) ? '=' . implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2)) : '=' . strtoupper(bin2hex($str[$i])); + $chr = ($this->charset === 'UTF-8' && extension_loaded('iconv')) ? '=' . implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2)) : '=' . strtoupper(bin2hex($str[$i])); // RFC 2045 sets a limit of 76 characters per line. // We'll append ?= to the end of each line though. if ($length + ($l = static::strlen($chr)) > 74) @@ -1652,7 +1643,7 @@ catch (\ErrorException $e) { $success = false; - $this->logger->error('Email: ' . $method . ' throwed ' . $e->getMessage()); + log_message('error', 'Email: ' . $method . ' throwed ' . $e->getMessage()); } if (! $success) { @@ -1801,7 +1792,7 @@ } // perform dot transformation on any lines that begin with a dot $this->sendData($this->headerStr . preg_replace('/^\./m', '..$1', $this->finalBody)); - $this->sendData('.'); + $this->sendData($this->newline . '.'); $reply = $this->getSMTPData(); $this->setErrorMessage($reply); $this->SMTPEnd(); diff --git a/system/Encryption/EncrypterInterface.php b/system/Encryption/EncrypterInterface.php index 3a3ff7c..4b008ad 100644 --- a/system/Encryption/EncrypterInterface.php +++ b/system/Encryption/EncrypterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Encryption/Encryption.php b/system/Encryption/Encryption.php index 16f15f8..1f047f6 100644 --- a/system/Encryption/Encryption.php +++ b/system/Encryption/Encryption.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,7 @@ use Config\Encryption as EncryptionConfig; use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Config\BaseConfig; -use CodeIgniter\Config\Services; +use Config\Services; /** * CodeIgniter Encryption Manager diff --git a/system/Encryption/Handlers/BaseHandler.php b/system/Encryption/Handlers/BaseHandler.php index 1efd401..62eb6b1 100644 --- a/system/Encryption/Handlers/BaseHandler.php +++ b/system/Encryption/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Encryption/Handlers/OpenSSLHandler.php b/system/Encryption/Handlers/OpenSSLHandler.php index ddaa8cb..72b6023 100644 --- a/system/Encryption/Handlers/OpenSSLHandler.php +++ b/system/Encryption/Handlers/OpenSSLHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Entity.php b/system/Entity.php index 63a984e..94153d0 100644 --- a/system/Entity.php +++ b/system/Entity.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -313,7 +313,7 @@ $result = $this->mutateDate($result); } // Or cast it as something? - else if ($this->_cast && isset($this->casts[$key]) && ! empty($this->casts[$key])) + else if ($this->_cast && ! empty($this->casts[$key])) { $result = $this->castAs($result, $this->casts[$key]); } @@ -471,7 +471,7 @@ return $key; } - if (isset($this->datamap[$key]) && ! empty($this->datamap[$key])) + if (! empty($this->datamap[$key])) { return $this->datamap[$key]; } @@ -602,7 +602,7 @@ $tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null; if (function_exists('json_decode')) { - if ((is_string($value) && strlen($value) > 1 && in_array($value{0}, ['[', '{', '"'])) || is_numeric($value)) + if ((is_string($value) && strlen($value) > 1 && in_array($value[0], ['[', '{', '"'])) || is_numeric($value)) { $tmp = json_decode($value, $asArray); diff --git a/system/Events/Events.php b/system/Events/Events.php index ae1f69a..c616256 100644 --- a/system/Events/Events.php +++ b/system/Events/Events.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Files/File.php b/system/Files/File.php index 69a5a4b..15ff417 100644 --- a/system/Files/File.php +++ b/system/Files/File.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/CSRF.php b/system/Filters/CSRF.php index 193911f..1f0bcf8 100644 --- a/system/Filters/CSRF.php +++ b/system/Filters/CSRF.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/DebugToolbar.php b/system/Filters/DebugToolbar.php index 78e8653..465ca3e 100644 --- a/system/Filters/DebugToolbar.php +++ b/system/Filters/DebugToolbar.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/FilterInterface.php b/system/Filters/FilterInterface.php index 97bf806..d58be9e 100644 --- a/system/Filters/FilterInterface.php +++ b/system/Filters/FilterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index b9832e9..853e135 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php index 4faffd6..aea08c3 100644 --- a/system/Filters/Honeypot.php +++ b/system/Filters/Honeypot.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/FormatterInterface.php b/system/Format/FormatterInterface.php index c50be49..17bc693 100644 --- a/system/Format/FormatterInterface.php +++ b/system/Format/FormatterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/JSONFormatter.php b/system/Format/JSONFormatter.php index 6beb88d..50caf39 100644 --- a/system/Format/JSONFormatter.php +++ b/system/Format/JSONFormatter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index d45942c..3e262d6 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php index 28b6616..f9c4838 100644 --- a/system/HTTP/CLIRequest.php +++ b/system/HTTP/CLIRequest.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index ddf1cbb..c5506ac 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index ebac8cb..713312f 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index f394543..080f6b2 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Exceptions/HTTPException.php b/system/HTTP/Exceptions/HTTPException.php index dc9f48e..5aa4895 100644 --- a/system/HTTP/Exceptions/HTTPException.php +++ b/system/HTTP/Exceptions/HTTPException.php @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Files/FileCollection.php b/system/HTTP/Files/FileCollection.php index 95f51cb..567ddf7 100644 --- a/system/HTTP/Files/FileCollection.php +++ b/system/HTTP/Files/FileCollection.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -310,7 +310,7 @@ */ protected function getValueDotNotationSyntax(array $index, array $value) { - if (is_array($index) && ! empty($index)) + if (! empty($index)) { $current_index = array_shift($index); } diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index d7ff326..1826a7a 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Files/UploadedFileInterface.php b/system/HTTP/Files/UploadedFileInterface.php index 7aa5aaa..64d74ad 100644 --- a/system/HTTP/Files/UploadedFileInterface.php +++ b/system/HTTP/Files/UploadedFileInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Header.php b/system/HTTP/Header.php index ff92ffa..0e75fa2 100644 --- a/system/HTTP/Header.php +++ b/system/HTTP/Header.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 51fc61f..0b363cd 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -43,7 +43,7 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\HTTP\Files\FileCollection; use CodeIgniter\HTTP\Files\UploadedFile; -use CodeIgniter\Config\Services; +use Config\Services; /** * Class IncomingRequest @@ -174,6 +174,11 @@ $this->populateHeaders(); + // Get our current URI. + // NOTE: This WILL NOT match the actual URL in the browser since for + // everything this cares about (and the router, etc) is the portion + // AFTER the script name. So, if hosted in a sub-folder this will + // appear different than actual URL. If you need that, use current_url(). $this->uri = $uri; $this->detectURI($config->uriProtocol, $config->baseURL); @@ -604,14 +609,10 @@ // baseURL, so let's help them out. $baseURL = ! empty($baseURL) ? rtrim($baseURL, '/ ') . '/' : $baseURL; - // Based on our baseURL provided by the developer (if set) + // Based on our baseURL provided by the developer // set our current domain name, scheme if (! empty($baseURL)) { - // We cannot add the path here, otherwise it's possible - // that the routing will not work correctly if we are - // within a sub-folder scheme. So it's modified in - // the $this->uri->setScheme(parse_url($baseURL, PHP_URL_SCHEME)); $this->uri->setHost(parse_url($baseURL, PHP_URL_HOST)); $this->uri->setPort(parse_url($baseURL, PHP_URL_PORT)); @@ -715,7 +716,8 @@ } // parse_url() returns false if no host is present, but the path or query string - // contains a colon followed by a number + // contains a colon followed by a number. So we attach a dummy host since + // REQUEST_URI does not include the host. This allows us to parse out the query string and path. $parts = parse_url('http://dummy' . $_SERVER['REQUEST_URI']); $query = $parts['query'] ?? ''; $uri = $parts['path'] ?? ''; diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php index ba7c5a2..1afb1d5 100644 --- a/system/HTTP/Message.php +++ b/system/HTTP/Message.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -84,7 +84,7 @@ /** * Message body * - * @var string + * @var mixed */ protected $body; @@ -108,7 +108,7 @@ /** * Sets the body of the current message. * - * @param $data + * @param mixed $data * * @return Message|Response */ diff --git a/system/HTTP/Negotiate.php b/system/HTTP/Negotiate.php index 4033d7d..6ac2d06 100644 --- a/system/HTTP/Negotiate.php +++ b/system/HTTP/Negotiate.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index abcf262..8b81077 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -92,7 +92,7 @@ throw HTTPException::forInvalidRedirectRoute($route); } - return $this->redirect(base_url($route), $method, $code); + return $this->redirect(site_url($route), $method, $code); } /** diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index ffb90c0..b8b222e 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/RequestInterface.php b/system/HTTP/RequestInterface.php index b88bdbe..fd8f8b3 100644 --- a/system/HTTP/RequestInterface.php +++ b/system/HTTP/RequestInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 80b9366..dca44d2 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -239,13 +239,10 @@ // Also ensures that a Cache-control header exists. $this->noCache(); - // Are we enforcing a Content Security Policy? - if ($config->CSPEnabled === true) - { - $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); - $this->CSPEnabled = true; - } + // We need CSP object even if not enabled to avoid calls to non existing methods + $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); + $this->CSPEnabled = $config->CSPEnabled; $this->cookiePrefix = $config->cookiePrefix; $this->cookieDomain = $config->cookieDomain; $this->cookiePath = $config->cookiePath; @@ -448,9 +445,9 @@ * * @return $this */ - public function setJSON($body) + public function setJSON($body, bool $unencoded = false) { - $this->body = $this->formatBody($body, 'json'); + $this->body = $this->formatBody($body, 'json' . ($unencoded ? '-unencoded' : '')); return $this; } @@ -538,12 +535,12 @@ */ protected function formatBody($body, string $format) { - $mime = "application/{$format}"; + $this->bodyFormat = ($format === 'json-unencoded' ? 'json' : $format); + $mime = "application/{$this->bodyFormat}"; $this->setContentType($mime); - $this->bodyFormat = $format; // Nothing much to do for a string... - if (! is_string($body)) + if (! is_string($body) || $format === 'json-unencoded') { /** * @var Format $config @@ -713,7 +710,7 @@ // Per spec, MUST be sent with each request, if possible. // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html - if (! isset($this->headers['Date'])) + if (! isset($this->headers['Date']) && php_sapi_name() !== 'cli-server') { $this->setDate(\DateTime::createFromFormat('U', (string) time())); } @@ -724,7 +721,7 @@ // Send all of our headers foreach ($this->getHeaders() as $name => $values) { - header($name . ': ' . $this->getHeaderLine($name), false, $this->statusCode); + header($name . ': ' . $this->getHeaderLine($name), true, $this->statusCode); } return $this; diff --git a/system/HTTP/ResponseInterface.php b/system/HTTP/ResponseInterface.php index 2ea6c6e..b39339d 100644 --- a/system/HTTP/ResponseInterface.php +++ b/system/HTTP/ResponseInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 33f0081..001b0a9 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -749,27 +749,7 @@ $query = substr($query, 1); } - $temp = explode('&', $query); - $parts = []; - - foreach ($temp as $index => $part) - { - list($key, $value) = $this->splitQueryPart($part); - - // Only 1 part? - if (is_null($value)) - { - $parts[$key] = null; - continue; - } - - // URL Decode the value to protect - // from double-encoding a URL. - // Especially useful with the Pager. - $parts[$this->decode($key)] = $this->decode($value); - } - - $this->query = $parts; + parse_str($query, $this->query); return $this; } @@ -777,53 +757,6 @@ //-------------------------------------------------------------------- /** - * Checks the value to see if it has been urlencoded and decodes it if so. - * The urlencode check is not perfect but should catch most cases. - * - * @param string $value - * - * @return string - */ - protected function decode(string $value): string - { - if (empty($value)) - { - return $value; - } - - $decoded = urldecode($value); - - // This won't catch all cases, specifically - // changing ' ' to '+' has the same length - // but doesn't really matter for our cases here. - return strlen($decoded) < strlen($value) ? $decoded : $value; - } - - /** - * Split a query value into it's key/value elements, if both - * are present. - * - * @param $part - * - * @return array|null - */ - protected function splitQueryPart(string $part) - { - $parts = explode('=', $part, 2); - - // If there's only a single element, no pair, - // then we return null - if (count($parts) === 1) - { - $parts = null; - } - - return $parts; - } - - //-------------------------------------------------------------------- - - /** * A convenience method to pass an array of items in as the Query * portion of the URI. * diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index 8dc292e..6e5b596 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/array_helper.php b/system/Helpers/array_helper.php index 518c8ae..9c5d8f6 100644 --- a/system/Helpers/array_helper.php +++ b/system/Helpers/array_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php index a704671..d85f644 100755 --- a/system/Helpers/cookie_helper.php +++ b/system/Helpers/cookie_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/date_helper.php b/system/Helpers/date_helper.php index 5ecf9f7..6cf362a 100644 --- a/system/Helpers/date_helper.php +++ b/system/Helpers/date_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php index 62e7f12..1ead233 100644 --- a/system/Helpers/filesystem_helper.php +++ b/system/Helpers/filesystem_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index a260980..82c809c 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 72891a6..3084771 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -51,11 +51,11 @@ * Generates an HTML unordered list from an single or * multi-dimensional array. * - * @param array $list - * @param string $attributes HTML attributes + * @param array $list + * @param mixed $attributes HTML attributes string, array, object * @return string */ - function ul(array $list, string $attributes = ''): string + function ul(array $list, $attributes = ''): string { return _list('ul', $list, $attributes); } @@ -70,11 +70,11 @@ * * Generates an HTML ordered list from an single or multi-dimensional array. * - * @param array $list - * @param string $attributes HTML attributes + * @param array $list + * @param mixed $attributes HTML attributes string, array, object * @return string */ - function ol(array $list, string $attributes = ''): string + function ol(array $list, $attributes = ''): string { return _list('ol', $list, $attributes); } @@ -91,11 +91,11 @@ * * @param string $type * @param mixed $list - * @param string $attributes + * @param mixed $attributes string, array, object * @param integer $depth * @return string */ - function _list(string $type = 'ul', $list = [], string $attributes = '', int $depth = 0): string + function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0): string { // Set the indentation based on the depth $out = str_repeat(' ', $depth) diff --git a/system/Helpers/inflector_helper.php b/system/Helpers/inflector_helper.php index 9389af0..cca140d 100755 --- a/system/Helpers/inflector_helper.php +++ b/system/Helpers/inflector_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index 2bcc3ed..d1baf76 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/security_helper.php b/system/Helpers/security_helper.php index 26ef455..4a324a2 100644 --- a/system/Helpers/security_helper.php +++ b/system/Helpers/security_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index 2bd189c..e4c5e2c 100755 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 9445f18..22813b3 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -111,7 +111,14 @@ // otherwise get rid of the path, because we have // no way of knowing the intent... $config = \CodeIgniter\Config\Services::request()->config; - $url = new \CodeIgniter\HTTP\URI($config->baseURL); + + // If baseUrl does not have a trailing slash it won't resolve + // correctly for users hosting in a subfolder. + $baseUrl = ! empty($config->baseURL) && $config->baseURL !== '/' + ? rtrim($config->baseURL, '/ ') . '/' + : $config->baseURL; + + $url = new \CodeIgniter\HTTP\URI($baseUrl); unset($config); // Merge in the path set by the user, if any @@ -132,7 +139,7 @@ $url->setScheme($protocol); } - return (string) $url; + return rtrim((string) $url, '/ '); } } @@ -152,7 +159,25 @@ */ function current_url(bool $returnObject = false) { - return $returnObject ? \CodeIgniter\Config\Services::request()->uri : (string) \CodeIgniter\Config\Services::request()->uri; + $uri = clone service('request')->uri; + + // If hosted in a sub-folder, we will have additional + // segments that show up prior to the URI path we just + // grabbed from the request, so add it on if necessary. + $baseUri = new \CodeIgniter\HTTP\URI(config('App')->baseURL); + + if (! empty($baseUri->getPath())) + { + $path = rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath(); + + $uri->setPath($path); + } + + // Since we're basing off of the IncomingRequest URI, + // we are guaranteed to have a host based on our own configs. + return $returnObject + ? $uri + : (string)$uri->setQuery(''); } } @@ -397,9 +422,9 @@ } else { - for ($i = 0, $l = strlen($attributes); $i < $l; $i ++) + for ($i = 0, $l = mb_strlen($attributes); $i < $l; $i ++) { - $x[] = $attributes[$i]; + $x[] = mb_substr($attributes, $i, 1); } } } diff --git a/system/Helpers/xml_helper.php b/system/Helpers/xml_helper.php index 8209b03..170a896 100644 --- a/system/Helpers/xml_helper.php +++ b/system/Helpers/xml_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Honeypot/Honeypot.php b/system/Honeypot/Honeypot.php index 68d5a62..406e43c 100644 --- a/system/Honeypot/Honeypot.php +++ b/system/Honeypot/Honeypot.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/I18n/Time.php b/system/I18n/Time.php index b26e7fe..a11d7e1 100644 --- a/system/I18n/Time.php +++ b/system/I18n/Time.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/I18n/TimeDifference.php b/system/I18n/TimeDifference.php index 637b448..abfbf76 100644 --- a/system/I18n/TimeDifference.php +++ b/system/I18n/TimeDifference.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 1c06265..3bd61e8 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index 41cb7b4..7f24af5 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 97f4a1a..d786166 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Image.php b/system/Images/Image.php index 1ffe87b..904c78b 100644 --- a/system/Images/Image.php +++ b/system/Images/Image.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/ImageHandlerInterface.php b/system/Images/ImageHandlerInterface.php index d0631e8..7727b5f 100644 --- a/system/Images/ImageHandlerInterface.php +++ b/system/Images/ImageHandlerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/Language.php b/system/Language/Language.php index 1abe60d..65cf58d 100644 --- a/system/Language/Language.php +++ b/system/Language/Language.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ namespace CodeIgniter\Language; -use CodeIgniter\Config\Services; +use Config\Services; /** * Handle system messages and localization. diff --git a/system/Language/en/CLI.php b/system/Language/en/CLI.php index 06eeee3..1afd4f2 100644 --- a/system/Language/en/CLI.php +++ b/system/Language/en/CLI.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Cache.php b/system/Language/en/Cache.php index a89cd87..a6a7038 100644 --- a/system/Language/en/Cache.php +++ b/system/Language/en/Cache.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Cast.php b/system/Language/en/Cast.php index 9d39682..f299df8 100644 --- a/system/Language/en/Cast.php +++ b/system/Language/en/Cast.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Core.php b/system/Language/en/Core.php index a78fc42..d5a49f9 100644 --- a/system/Language/en/Core.php +++ b/system/Language/en/Core.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Database.php b/system/Language/en/Database.php index 08748e3..da88895 100644 --- a/system/Language/en/Database.php +++ b/system/Language/en/Database.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Email.php b/system/Language/en/Email.php index b99117b..6f9fcc4 100644 --- a/system/Language/en/Email.php +++ b/system/Language/en/Email.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Encryption.php b/system/Language/en/Encryption.php index ddf1543..4b4e64c 100644 --- a/system/Language/en/Encryption.php +++ b/system/Language/en/Encryption.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Entity.php b/system/Language/en/Entity.php index 52a014a..1e9fc5e 100644 --- a/system/Language/en/Entity.php +++ b/system/Language/en/Entity.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @filesource diff --git a/system/Language/en/Files.php b/system/Language/en/Files.php index e952144..6ff4878 100644 --- a/system/Language/en/Files.php +++ b/system/Language/en/Files.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Filters.php b/system/Language/en/Filters.php index bc1a882..7a757b2 100644 --- a/system/Language/en/Filters.php +++ b/system/Language/en/Filters.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Format.php b/system/Language/en/Format.php index 0753dd2..c0070c8 100644 --- a/system/Language/en/Format.php +++ b/system/Language/en/Format.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/HTTP.php b/system/Language/en/HTTP.php index 9f94419..2407c0b 100644 --- a/system/Language/en/HTTP.php +++ b/system/Language/en/HTTP.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ 'cannotSetFilepath' => 'When setting binary can not set filepath: {0}', 'notFoundDownloadSource' => 'Not found download body source.', 'cannotSetCache' => 'It does not supported caching for downloading.', - 'cannotSetStatusCode' => 'It does not supported chnage status code for downloading. code: {0}, reason: {1}', + 'cannotSetStatusCode' => 'It does not supported change status code for downloading. code: {0}, reason: {1}', // Response 'missingResponseStatus' => 'HTTP Response is missing a status code', diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index 740b9e8..9d11da5 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Language.php b/system/Language/en/Language.php index efd395b..5d38ee7 100644 --- a/system/Language/en/Language.php +++ b/system/Language/en/Language.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Log.php b/system/Language/en/Log.php index 8afd8f6..0c8498d 100644 --- a/system/Language/en/Log.php +++ b/system/Language/en/Log.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Migrations.php b/system/Language/en/Migrations.php index efcc94c..efbac6d 100644 --- a/system/Language/en/Migrations.php +++ b/system/Language/en/Migrations.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Number.php b/system/Language/en/Number.php index ec8ea47..149d8a4 100644 --- a/system/Language/en/Number.php +++ b/system/Language/en/Number.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Pager.php b/system/Language/en/Pager.php index 3d4ad91..6e156c4 100644 --- a/system/Language/en/Pager.php +++ b/system/Language/en/Pager.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/RESTful.php b/system/Language/en/RESTful.php index c5d2389..69262a6 100644 --- a/system/Language/en/RESTful.php +++ b/system/Language/en/RESTful.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Redirect.php b/system/Language/en/Redirect.php index 050b97b..da77f14 100644 --- a/system/Language/en/Redirect.php +++ b/system/Language/en/Redirect.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Router.php b/system/Language/en/Router.php index 97b76b5..b305b54 100644 --- a/system/Language/en/Router.php +++ b/system/Language/en/Router.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Session.php b/system/Language/en/Session.php index 5f0dabd..0d12ff0 100644 --- a/system/Language/en/Session.php +++ b/system/Language/en/Session.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Time.php b/system/Language/en/Time.php index ece5f76..92fdf47 100644 --- a/system/Language/en/Time.php +++ b/system/Language/en/Time.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Validation.php b/system/Language/en/Validation.php index c9e656f..ac047df 100644 --- a/system/Language/en/Validation.php +++ b/system/Language/en/Validation.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -34,10 +34,12 @@ 'exact_length' => 'The {field} field must be exactly {param} characters in length.', 'greater_than' => 'The {field} field must contain a number greater than {param}.', 'greater_than_equal_to' => 'The {field} field must contain a number greater than or equal to {param}.', + 'hex' => 'The {field} field may only contain hexidecimal characters.', 'in_list' => 'The {field} field must be one of: {param}.', 'integer' => 'The {field} field must contain an integer.', 'is_natural' => 'The {field} field must only contain digits.', 'is_natural_no_zero' => 'The {field} field must only contain digits and must be greater than zero.', + 'is_not_unique' => 'The {field} field must contain a previously existing value in the database.', 'is_unique' => 'The {field} field must contain a unique value.', 'less_than' => 'The {field} field must contain a number less than {param}.', 'less_than_equal_to' => 'The {field} field must contain a number less than or equal to {param}.', diff --git a/system/Language/en/View.php b/system/Language/en/View.php index 0c2a146..eb49e1c 100644 --- a/system/Language/en/View.php +++ b/system/Language/en/View.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Handlers/BaseHandler.php b/system/Log/Handlers/BaseHandler.php index 4b76f89..6874d38 100644 --- a/system/Log/Handlers/BaseHandler.php +++ b/system/Log/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php index 6af3527..bdcd318 100644 --- a/system/Log/Handlers/ChromeLoggerHandler.php +++ b/system/Log/Handlers/ChromeLoggerHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -41,7 +41,7 @@ use CodeIgniter\Events\Events; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Config\Services; +use Config\Services; /** * Class ChromeLoggerHandler diff --git a/system/Log/Handlers/FileHandler.php b/system/Log/Handlers/FileHandler.php index d83750e..78a3218 100644 --- a/system/Log/Handlers/FileHandler.php +++ b/system/Log/Handlers/FileHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -79,7 +79,7 @@ $this->path = $config['path'] ?? WRITEPATH . 'logs/'; - $this->fileExtension = $config['fileExtension'] ?? 'php'; + $this->fileExtension = empty($config['fileExtension']) ? 'log' : $config['fileExtension']; $this->fileExtension = ltrim($this->fileExtension, '.'); $this->filePermissions = $config['filePermissions'] ?? 0644; diff --git a/system/Log/Handlers/HandlerInterface.php b/system/Log/Handlers/HandlerInterface.php index 0e0d01b..6778a46 100644 --- a/system/Log/Handlers/HandlerInterface.php +++ b/system/Log/Handlers/HandlerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Logger.php b/system/Log/Logger.php index 2219d57..5e95ffd 100644 --- a/system/Log/Logger.php +++ b/system/Log/Logger.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Model.php b/system/Model.php index 8749b2c..38a5488 100644 --- a/system/Model.php +++ b/system/Model.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -242,6 +242,14 @@ protected $skipValidation = false; /** + * Whether rules should be removed that do not exist + * in the passed in data. Used between inserts/updates. + * + * @var boolean + */ + protected $cleanValidationRules = true; + + /** * Our validator instance. * * @var \CodeIgniter\Validation\Validation @@ -381,12 +389,12 @@ $row = $row->getResult($this->tempReturnType); } - $row = $this->trigger('afterFind', ['id' => $id, 'data' => $row]); + $eventData = $this->trigger('afterFind', ['id' => $id, 'data' => $row]); $this->tempReturnType = $this->returnType; $this->tempUseSoftDeletes = $this->useSoftDeletes; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -438,12 +446,12 @@ $row = $row->getResult($this->tempReturnType); - $row = $this->trigger('afterFind', ['data' => $row, 'limit' => $limit, 'offset' => $offset]); + $eventData = $this->trigger('afterFind', ['data' => $row, 'limit' => $limit, 'offset' => $offset]); $this->tempReturnType = $this->returnType; $this->tempUseSoftDeletes = $this->useSoftDeletes; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -475,11 +483,11 @@ $row = $row->getFirstRow($this->tempReturnType); - $row = $this->trigger('afterFind', ['data' => $row]); + $eventData = $this->trigger('afterFind', ['data' => $row]); $this->tempReturnType = $this->returnType; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -682,7 +690,7 @@ // Validate data before saving. if ($this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(false)->validate($data) === false) { return false; } @@ -705,11 +713,11 @@ $data[$this->updatedField] = $date; } - $data = $this->trigger('beforeInsert', ['data' => $data]); + $eventData = $this->trigger('beforeInsert', ['data' => $data]); // Must use the set() method to ensure objects get converted to arrays $result = $this->builder() - ->set($data['data'], '', $escape) + ->set($eventData['data'], '', $escape) ->insert(); // If insertion succeeded then save the insert ID @@ -719,7 +727,7 @@ } // Trigger afterInsert events with the inserted data and new ID - $this->trigger('afterInsert', ['id' => $this->insertID, 'data' => $data, 'result' => $result]); + $this->trigger('afterInsert', ['id' => $this->insertID, 'data' => $eventData['data'], 'result' => $result]); // If insertion failed, get out of here if (! $result) @@ -750,7 +758,7 @@ { foreach ($set as $row) { - if ($this->validate($row) === false) + if ($this->cleanRules(false)->validate($row) === false) { return false; } @@ -812,7 +820,7 @@ // Validate data before saving. if ($this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(true)->validate($data) === false) { return false; } @@ -827,7 +835,7 @@ $data[$this->updatedField] = $this->setDate(); } - $data = $this->trigger('beforeUpdate', ['id' => $id, 'data' => $data]); + $eventData = $this->trigger('beforeUpdate', ['id' => $id, 'data' => $data]); $builder = $this->builder(); @@ -838,10 +846,10 @@ // Must use the set() method to ensure objects get converted to arrays $result = $builder - ->set($data['data'], '', $escape) + ->set($eventData['data'], '', $escape) ->update(); - $this->trigger('afterUpdate', ['id' => $id, 'data' => $data, 'result' => $result]); + $this->trigger('afterUpdate', ['id' => $id, 'data' => $eventData['data'], 'result' => $result]); return $result; } @@ -867,7 +875,7 @@ { foreach ($set as $row) { - if ($this->validate($row) === false) + if ($this->cleanRules(true)->validate($row) === false) { return false; } @@ -1005,7 +1013,7 @@ // Validate data before saving. if (! empty($data) && $this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(true)->validate($data) === false) { return false; } @@ -1114,14 +1122,13 @@ */ public function paginate(int $perPage = 20, string $group = 'default', int $page = 0) { - // Get the necessary parts. - $page = $page >= 1 ? $page : (ctype_digit($_GET['page'] ?? '') && $_GET['page'] > 1 ? $_GET['page'] : 1); + $pager = \Config\Services::pager(null, null, false); + $page = $page >= 1 ? $page : $pager->getCurrentPage($group); $total = $this->countAllResults(false); // Store it in the Pager library so it can be // paginated in the views. - $pager = \Config\Services::pager(); $this->pager = $pager->store($group, $page, $perPage, $total); $offset = ($page - 1) * $perPage; @@ -1360,6 +1367,23 @@ //-------------------------------------------------------------------- /** + * Should validation rules be removed before saving? + * Most handy when doing updates. + * + * @param boolean $choice + * + * @return $this + */ + public function cleanRules(bool $choice = false) + { + $this->cleanValidationRules = $choice; + + return $this; + } + + //-------------------------------------------------------------------- + + /** * Validate the data against the validation rules (or the validation group) * specified in the class property, $validationRules. * @@ -1390,7 +1414,9 @@ $rules = $this->validation->loadRuleGroup($rules); } - $rules = $this->cleanValidationRules($rules, $data); + $rules = $this->cleanValidationRules + ? $this->cleanValidationRules($rules, $data) + : $rules; // If no data existed that needs validation // our job is done here. @@ -1564,22 +1590,22 @@ * It is the responsibility of the callback methods to return * the data itself. * - * Each $data array MUST have a 'data' key with the relevant + * Each $eventData array MUST have a 'data' key with the relevant * data for callback methods (like an array of key/value pairs to insert * or update, an array of results, etc) * * @param string $event - * @param array $data + * @param array $eventData * * @return mixed * @throws \CodeIgniter\Database\Exceptions\DataException */ - protected function trigger(string $event, array $data) + protected function trigger(string $event, array $eventData) { // Ensure it's a valid event if (! isset($this->{$event}) || empty($this->{$event})) { - return $data; + return $eventData; } foreach ($this->{$event} as $callback) @@ -1589,10 +1615,10 @@ throw DataException::forInvalidMethodTriggered($callback); } - $data = $this->{$callback}($data); + $eventData = $this->{$callback}($eventData); } - return $data; + return $eventData; } //-------------------------------------------------------------------- diff --git a/system/Pager/Pager.php b/system/Pager/Pager.php index b80b0e8..8aecd5f 100644 --- a/system/Pager/Pager.php +++ b/system/Pager/Pager.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -348,7 +348,7 @@ } else { - $uri->addQuery('page', $page); + $uri->addQuery($this->groups[$group]['pageSelector'], $page); } if ($this->only) @@ -357,7 +357,7 @@ if (! $segment) { - $query['page'] = $page; + $query[$this->groups[$group]['pageSelector']] = $page; } $uri->setQueryArray($query); @@ -503,13 +503,31 @@ } $this->groups[$group] = [ - 'uri' => clone Services::request()->uri, - 'hasMore' => false, - 'total' => null, - 'perPage' => $this->config->perPage, - 'pageCount' => 1, + 'uri' => clone current_url(true), + 'hasMore' => false, + 'total' => null, + 'perPage' => $this->config->perPage, + 'pageCount' => 1, + 'pageSelector' => $group === 'default' ? 'page' : 'page_' . $group, ]; + $this->calculateCurrentPage($group); + + if ($_GET) + { + $this->groups[$group]['uri'] = $this->groups[$group]['uri']->setQueryArray($_GET); + } + } + + //-------------------------------------------------------------------- + + /** + * Calculating the current page + * + * @param string $group + */ + protected function calculateCurrentPage(string $group) + { if (array_key_exists($group, $this->segment)) { try @@ -523,12 +541,11 @@ } else { - $this->groups[$group]['currentPage'] = $_GET['page_' . $group] ?? $_GET['page'] ?? 1; - } + $pageSelector = $this->groups[$group]['pageSelector']; - if ($_GET) - { - $this->groups[$group]['uri'] = $this->groups[$group]['uri']->setQueryArray($_GET); + $page = (int) ($_GET[$pageSelector] ?? 1); + + $this->groups[$group]['currentPage'] = $page < 1 ? 1 : $page; } } diff --git a/system/Pager/PagerInterface.php b/system/Pager/PagerInterface.php index 5a56bc4..9f975b5 100644 --- a/system/Pager/PagerInterface.php +++ b/system/Pager/PagerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Pager/PagerRenderer.php b/system/Pager/PagerRenderer.php index c21ba40..1712ddf 100644 --- a/system/Pager/PagerRenderer.php +++ b/system/Pager/PagerRenderer.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -93,6 +93,12 @@ * @var integer */ protected $segment; + /** + * Name of $_GET parameter + * + * @var integer + */ + protected $pageSelector; //-------------------------------------------------------------------- @@ -103,13 +109,14 @@ */ public function __construct(array $details) { - $this->first = 1; - $this->last = $details['pageCount']; - $this->current = $details['currentPage']; - $this->total = $details['total']; - $this->uri = $details['uri']; - $this->pageCount = $details['pageCount']; - $this->segment = $details['segment'] ?? 0; + $this->first = 1; + $this->last = $details['pageCount']; + $this->current = $details['currentPage']; + $this->total = $details['total']; + $this->uri = $details['uri']; + $this->pageCount = $details['pageCount']; + $this->segment = $details['segment'] ?? 0; + $this->pageSelector = $details['pageSelector'] ?? 'page'; } //-------------------------------------------------------------------- @@ -164,7 +171,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->first - 1); + $uri->addQuery($this->pageSelector, $this->first - 1); } else { @@ -208,7 +215,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->last + 1); + $uri->addQuery($this->pageSelector, $this->last + 1); } else { @@ -231,7 +238,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', 1); + $uri->addQuery($this->pageSelector, 1); } else { @@ -254,7 +261,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->pageCount); + $uri->addQuery($this->pageSelector, $this->pageCount); } else { @@ -277,7 +284,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->current); + $uri->addQuery($this->pageSelector, $this->current); } else { @@ -306,7 +313,7 @@ for ($i = $this->first; $i <= $this->last; $i ++) { $links[] = [ - 'uri' => (string) ($this->segment === 0 ? $uri->addQuery('page', $i) : $uri->setSegment($this->segment, $i)), + 'uri' => (string) ($this->segment === 0 ? $uri->addQuery($this->pageSelector, $i) : $uri->setSegment($this->segment, $i)), 'title' => (int) $i, 'active' => ($i === $this->current), ]; diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 3ca495d..4aaec7c 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/RESTful/ResourcePresenter.php b/system/RESTful/ResourcePresenter.php index 3ac0676..2d970e3 100644 --- a/system/RESTful/ResourcePresenter.php +++ b/system/RESTful/ResourcePresenter.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 6cc01b4..53a27e7 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -653,6 +653,10 @@ { $to = $this->routes['*'][$to]['route']; } + else if (array_key_exists($to, $this->routes['get'])) + { + $to = $this->routes['get'][$to]['route']; + } $this->create('*', $from, $to, ['redirect' => $status]); @@ -1382,7 +1386,7 @@ } // Limiting to subdomains? - else if (isset($options['subdomain']) && ! empty($options['subdomain'])) + else if (! empty($options['subdomain'])) { // If we don't match the current subdomain, then // we don't need to add the route. @@ -1420,7 +1424,7 @@ } // If no namespace found, add the default namespace - if (is_string($to) && strpos($to, '\\') === false) + if (is_string($to) && (strpos($to, '\\') === false || strpos($to, '\\') > 0)) { $namespace = $options['namespace'] ?? $this->defaultNamespace; $to = trim($namespace, '\\') . '\\' . $to; diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index a6ae721..b25e93d 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Router/Router.php b/system/Router/Router.php index 185e94f..14f24c6 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -424,6 +424,11 @@ // Does the RegEx match? if (preg_match('#^' . $key . '$#', $uri, $matches)) { + // Is this route supposed to redirect to another? + if ($this->collection->isRedirect($key)) + { + throw new RedirectException(key($val), $this->collection->getRedirectCode($key)); + } // Store our locale so CodeIgniter object can // assign it to the Request. if (isset($localeSegment)) @@ -482,12 +487,6 @@ $val = $controller . '::' . $method; } - // Is this route supposed to redirect to another? - if ($this->collection->isRedirect($key)) - { - throw new RedirectException($val, $this->collection->getRedirectCode($key)); - } - $this->setRequest(explode('/', $val)); $this->matchedRoute = [ diff --git a/system/Router/RouterInterface.php b/system/Router/RouterInterface.php index 7adb860..46cb285 100644 --- a/system/Router/RouterInterface.php +++ b/system/Router/RouterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Security/Security.php b/system/Security/Security.php index cef7815..28318d9 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/ArrayHandler.php b/system/Session/Handlers/ArrayHandler.php index 9f71ada..90eb920 100644 --- a/system/Session/Handlers/ArrayHandler.php +++ b/system/Session/Handlers/ArrayHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/BaseHandler.php b/system/Session/Handlers/BaseHandler.php index d9fa7fa..4d8264d 100644 --- a/system/Session/Handlers/BaseHandler.php +++ b/system/Session/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index 77ed74f..3290a3a 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/FileHandler.php b/system/Session/Handlers/FileHandler.php index f046b9d..19fc57f 100644 --- a/system/Session/Handlers/FileHandler.php +++ b/system/Session/Handlers/FileHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index 0fa2486..f35405e 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 900cd4b..513e0d2 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Session.php b/system/Session/Session.php index d0960db..ff40a47 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -497,7 +497,7 @@ */ public function get(string $key = null) { - if (! empty($key) && ! is_null($value = dot_array_search($key, $_SESSION))) + if (! empty($key) && ! is_null($value = dot_array_search($key, $_SESSION ?? []))) { return $value; } diff --git a/system/Session/SessionInterface.php b/system/Session/SessionInterface.php index 820419a..e098514 100644 --- a/system/Session/SessionInterface.php +++ b/system/Session/SessionInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/CIDatabaseTestCase.php b/system/Test/CIDatabaseTestCase.php index 9e177fc..926e1a9 100644 --- a/system/Test/CIDatabaseTestCase.php +++ b/system/Test/CIDatabaseTestCase.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index 4d2dc80..54208bf 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ControllerResponse.php b/system/Test/ControllerResponse.php index 1215842..a187ce7 100644 --- a/system/Test/ControllerResponse.php +++ b/system/Test/ControllerResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ControllerTester.php b/system/Test/ControllerTester.php index ed8fac6..d6dc0b6 100644 --- a/system/Test/ControllerTester.php +++ b/system/Test/ControllerTester.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -129,6 +129,11 @@ $this->appConfig = new App(); } + if (! $this->uri instanceof URI) + { + $this->uri = new URI($this->appConfig->baseURL ?? 'http://example.com'); + } + if (empty($this->request)) { $this->request = new IncomingRequest($this->appConfig, $this->uri, $this->body, new UserAgent()); diff --git a/system/Test/DOMParser.php b/system/Test/DOMParser.php index d0d6af8..1872a68 100644 --- a/system/Test/DOMParser.php +++ b/system/Test/DOMParser.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/FeatureResponse.php b/system/Test/FeatureResponse.php index 362161f..9f2b193 100644 --- a/system/Test/FeatureResponse.php +++ b/system/Test/FeatureResponse.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/FeatureTestCase.php b/system/Test/FeatureTestCase.php index 356b38a..6308988 100644 --- a/system/Test/FeatureTestCase.php +++ b/system/Test/FeatureTestCase.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/Filters/CITestStreamFilter.php b/system/Test/Filters/CITestStreamFilter.php index 449f688..4310a7f 100644 --- a/system/Test/Filters/CITestStreamFilter.php +++ b/system/Test/Filters/CITestStreamFilter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ReflectionHelper.php b/system/Test/ReflectionHelper.php index 2719b44..5bdfa98 100644 --- a/system/Test/ReflectionHelper.php +++ b/system/Test/ReflectionHelper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/ThirdParty/Escaper/Escaper.php b/system/ThirdParty/Escaper/Escaper.php new file mode 100644 index 0000000..9f903a5 --- /dev/null +++ b/system/ThirdParty/Escaper/Escaper.php @@ -0,0 +1,391 @@ + 'quot', // quotation mark + 38 => 'amp', // ampersand + 60 => 'lt', // less-than sign + 62 => 'gt', // greater-than sign + ]; + + /** + * Current encoding for escaping. If not UTF-8, we convert strings from this encoding + * pre-escaping and back to this encoding post-escaping. + * + * @var string + */ + protected $encoding = 'utf-8'; + + /** + * Holds the value of the special flags passed as second parameter to + * htmlspecialchars(). + * + * @var int + */ + protected $htmlSpecialCharsFlags; + + /** + * Static Matcher which escapes characters for HTML Attribute contexts + * + * @var callable + */ + protected $htmlAttrMatcher; + + /** + * Static Matcher which escapes characters for Javascript contexts + * + * @var callable + */ + protected $jsMatcher; + + /** + * Static Matcher which escapes characters for CSS Attribute contexts + * + * @var callable + */ + protected $cssMatcher; + + /** + * List of all encoding supported by this class + * + * @var array + */ + protected $supportedEncodings = [ + 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', + 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', + 'ibm866', '866', 'cp1251', 'windows-1251', + 'win-1251', '1251', 'cp1252', 'windows-1252', + '1252', 'koi8-r', 'koi8-ru', 'koi8r', + 'big5', '950', 'gb2312', '936', + 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', + 'cp932', '932', 'euc-jp', 'eucjp', + 'eucjp-win', 'macroman' + ]; + + /** + * Constructor: Single parameter allows setting of global encoding for use by + * the current object. + * + * @param string $encoding + * @throws Exception\InvalidArgumentException + */ + public function __construct($encoding = null) + { + if ($encoding !== null) { + if (! is_string($encoding)) { + throw new Exception\InvalidArgumentException( + get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) + ); + } + if ($encoding === '') { + throw new Exception\InvalidArgumentException( + get_class($this) . ' constructor parameter does not allow a blank value' + ); + } + + $encoding = strtolower($encoding); + if (! in_array($encoding, $this->supportedEncodings)) { + throw new Exception\InvalidArgumentException( + 'Value of \'' . $encoding . '\' passed to ' . get_class($this) + . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' + ); + } + + $this->encoding = $encoding; + } + + // We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences. + $this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE; + + // set matcher callbacks + $this->htmlAttrMatcher = [$this, 'htmlAttrMatcher']; + $this->jsMatcher = [$this, 'jsMatcher']; + $this->cssMatcher = [$this, 'cssMatcher']; + } + + /** + * Return the encoding that all output/input is expected to be encoded in. + * + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Escape a string for the HTML Body context where there are very few characters + * of special meaning. Internally this will use htmlspecialchars(). + * + * @param string $string + * @return string + */ + public function escapeHtml($string) + { + return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); + } + + /** + * Escape a string for the HTML Attribute context. We use an extended set of characters + * to escape that are not covered by htmlspecialchars() to cover cases where an attribute + * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). + * + * @param string $string + * @return string + */ + public function escapeHtmlAttr($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Escape a string for the Javascript context. This does not use json_encode(). An extended + * set of characters are escaped beyond ECMAScript's rules for Javascript literal string + * escaping in order to prevent misinterpretation of Javascript as HTML leading to the + * injection of special characters and entities. The escaping used should be tolerant + * of cases where HTML escaping was not applied on top of Javascript escaping correctly. + * Backslash escaping is not used as it still leaves the escaped character as-is and so + * is not useful in a HTML context. + * + * @param string $string + * @return string + */ + public function escapeJs($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Escape a string for the URI or Parameter contexts. This should not be used to escape + * an entire URI - only a subcomponent being inserted. The function is a simple proxy + * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. + * + * @param string $string + * @return string + */ + public function escapeUrl($string) + { + return rawurlencode($string); + } + + /** + * Escape a string for the CSS context. CSS escaping can be applied to any string being + * inserted into CSS and escapes everything except alphanumerics. + * + * @param string $string + * @return string + */ + public function escapeCss($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Callback function for preg_replace_callback that applies HTML Attribute + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function htmlAttrMatcher($matches) + { + $chr = $matches[0]; + $ord = ord($chr); + + /** + * The following replaces characters undefined in HTML with the + * hex entity for the Unicode replacement character. + */ + if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") + || ($ord >= 0x7f && $ord <= 0x9f) + ) { + return '�'; + } + + /** + * Check if the current character to escape has a name entity we should + * replace it with while grabbing the integer value of the character. + */ + if (strlen($chr) > 1) { + $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); + } + + $hex = bin2hex($chr); + $ord = hexdec($hex); + if (isset(static::$htmlNamedEntityMap[$ord])) { + return '&' . static::$htmlNamedEntityMap[$ord] . ';'; + } + + /** + * Per OWASP recommendations, we'll use upper hex entities + * for any other characters where a named entity does not exist. + */ + if ($ord > 255) { + return sprintf('&#x%04X;', $ord); + } + return sprintf('&#x%02X;', $ord); + } + + /** + * Callback function for preg_replace_callback that applies Javascript + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function jsMatcher($matches) + { + $chr = $matches[0]; + if (strlen($chr) == 1) { + return sprintf('\\x%02X', ord($chr)); + } + $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); + $hex = strtoupper(bin2hex($chr)); + if (strlen($hex) <= 4) { + return sprintf('\\u%04s', $hex); + } + $highSurrogate = substr($hex, 0, 4); + $lowSurrogate = substr($hex, 4, 4); + return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); + } + + /** + * Callback function for preg_replace_callback that applies CSS + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function cssMatcher($matches) + { + $chr = $matches[0]; + if (strlen($chr) == 1) { + $ord = ord($chr); + } else { + $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); + $ord = hexdec(bin2hex($chr)); + } + return sprintf('\\%X ', $ord); + } + + /** + * Converts a string to UTF-8 from the base encoding. The base encoding is set via this + * class' constructor. + * + * @param string $string + * @throws Exception\RuntimeException + * @return string + */ + protected function toUtf8($string) + { + if ($this->getEncoding() === 'utf-8') { + $result = $string; + } else { + $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); + } + + if (! $this->isUtf8($result)) { + throw new Exception\RuntimeException( + sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) + ); + } + + return $result; + } + + /** + * Converts a string from UTF-8 to the base encoding. The base encoding is set via this + * class' constructor. + * @param string $string + * @return string + */ + protected function fromUtf8($string) + { + if ($this->getEncoding() === 'utf-8') { + return $string; + } + + return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); + } + + /** + * Checks if a given string appears to be valid UTF-8 or not. + * + * @param string $string + * @return bool + */ + protected function isUtf8($string) + { + return ($string === '' || preg_match('/^./su', $string)); + } + + /** + * Encoding conversion helper which wraps iconv and mbstring where they exist or throws + * and exception where neither is available. + * + * @param string $string + * @param string $to + * @param array|string $from + * @throws Exception\RuntimeException + * @return string + */ + protected function convertEncoding($string, $to, $from) + { + if (function_exists('iconv')) { + $result = iconv($from, $to, $string); + } elseif (function_exists('mb_convert_encoding')) { + $result = mb_convert_encoding($string, $to, $from); + } else { + throw new Exception\RuntimeException( + get_class($this) + . ' requires either the iconv or mbstring extension to be installed' + . ' when escaping for non UTF-8 strings.' + ); + } + + if ($result === false) { + return ''; // return non-fatal blank string on encoding errors from users + } + return $result; + } +} diff --git a/system/ThirdParty/Escaper/Exception/ExceptionInterface.php b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php new file mode 100644 index 0000000..7ebe04e --- /dev/null +++ b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php @@ -0,0 +1,13 @@ + 'quot', // quotation mark - 38 => 'amp', // ampersand - 60 => 'lt', // less-than sign - 62 => 'gt', // greater-than sign - ]; - - /** - * Current encoding for escaping. If not UTF-8, we convert strings from this encoding - * pre-escaping and back to this encoding post-escaping. - * - * @var string - */ - protected $encoding = 'utf-8'; - - /** - * Holds the value of the special flags passed as second parameter to - * htmlspecialchars(). - * - * @var int - */ - protected $htmlSpecialCharsFlags; - - /** - * Static Matcher which escapes characters for HTML Attribute contexts - * - * @var callable - */ - protected $htmlAttrMatcher; - - /** - * Static Matcher which escapes characters for Javascript contexts - * - * @var callable - */ - protected $jsMatcher; - - /** - * Static Matcher which escapes characters for CSS Attribute contexts - * - * @var callable - */ - protected $cssMatcher; - - /** - * List of all encoding supported by this class - * - * @var array - */ - protected $supportedEncodings = [ - 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', - 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', - 'ibm866', '866', 'cp1251', 'windows-1251', - 'win-1251', '1251', 'cp1252', 'windows-1252', - '1252', 'koi8-r', 'koi8-ru', 'koi8r', - 'big5', '950', 'gb2312', '936', - 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', - 'cp932', '932', 'euc-jp', 'eucjp', - 'eucjp-win', 'macroman' - ]; - - /** - * Constructor: Single parameter allows setting of global encoding for use by - * the current object. - * - * @param string $encoding - * @throws Exception\InvalidArgumentException - */ - public function __construct($encoding = null) - { - if ($encoding !== null) { - if (! is_string($encoding)) { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) - ); - } - if ($encoding === '') { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter does not allow a blank value' - ); - } - - $encoding = strtolower($encoding); - if (! in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException( - 'Value of \'' . $encoding . '\' passed to ' . get_class($this) - . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' - ); - } - - $this->encoding = $encoding; - } - - // We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences. - $this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE; - - // set matcher callbacks - $this->htmlAttrMatcher = [$this, 'htmlAttrMatcher']; - $this->jsMatcher = [$this, 'jsMatcher']; - $this->cssMatcher = [$this, 'cssMatcher']; - } - - /** - * Return the encoding that all output/input is expected to be encoded in. - * - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Escape a string for the HTML Body context where there are very few characters - * of special meaning. Internally this will use htmlspecialchars(). - * - * @param string $string - * @return string - */ - public function escapeHtml($string) - { - return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); - } - - /** - * Escape a string for the HTML Attribute context. We use an extended set of characters - * to escape that are not covered by htmlspecialchars() to cover cases where an attribute - * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). - * - * @param string $string - * @return string - */ - public function escapeHtmlAttr($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the Javascript context. This does not use json_encode(). An extended - * set of characters are escaped beyond ECMAScript's rules for Javascript literal string - * escaping in order to prevent misinterpretation of Javascript as HTML leading to the - * injection of special characters and entities. The escaping used should be tolerant - * of cases where HTML escaping was not applied on top of Javascript escaping correctly. - * Backslash escaping is not used as it still leaves the escaped character as-is and so - * is not useful in a HTML context. - * - * @param string $string - * @return string - */ - public function escapeJs($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the URI or Parameter contexts. This should not be used to escape - * an entire URI - only a subcomponent being inserted. The function is a simple proxy - * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. - * - * @param string $string - * @return string - */ - public function escapeUrl($string) - { - return rawurlencode($string); - } - - /** - * Escape a string for the CSS context. CSS escaping can be applied to any string being - * inserted into CSS and escapes everything except alphanumerics. - * - * @param string $string - * @return string - */ - public function escapeCss($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Callback function for preg_replace_callback that applies HTML Attribute - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function htmlAttrMatcher($matches) - { - $chr = $matches[0]; - $ord = ord($chr); - - /** - * The following replaces characters undefined in HTML with the - * hex entity for the Unicode replacement character. - */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") - || ($ord >= 0x7f && $ord <= 0x9f) - ) { - return '�'; - } - - /** - * Check if the current character to escape has a name entity we should - * replace it with while grabbing the integer value of the character. - */ - if (strlen($chr) > 1) { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - } - - $hex = bin2hex($chr); - $ord = hexdec($hex); - if (isset(static::$htmlNamedEntityMap[$ord])) { - return '&' . static::$htmlNamedEntityMap[$ord] . ';'; - } - - /** - * Per OWASP recommendations, we'll use upper hex entities - * for any other characters where a named entity does not exist. - */ - if ($ord > 255) { - return sprintf('&#x%04X;', $ord); - } - return sprintf('&#x%02X;', $ord); - } - - /** - * Callback function for preg_replace_callback that applies Javascript - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function jsMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - return sprintf('\\x%02X', ord($chr)); - } - $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); - $hex = strtoupper(bin2hex($chr)); - if (strlen($hex) <= 4) { - return sprintf('\\u%04s', $hex); - } - $highSurrogate = substr($hex, 0, 4); - $lowSurrogate = substr($hex, 4, 4); - return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); - } - - /** - * Callback function for preg_replace_callback that applies CSS - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function cssMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - $ord = ord($chr); - } else { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - $ord = hexdec(bin2hex($chr)); - } - return sprintf('\\%X ', $ord); - } - - /** - * Converts a string to UTF-8 from the base encoding. The base encoding is set via this - * class' constructor. - * - * @param string $string - * @throws Exception\RuntimeException - * @return string - */ - protected function toUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - $result = $string; - } else { - $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); - } - - if (! $this->isUtf8($result)) { - throw new Exception\RuntimeException( - sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) - ); - } - - return $result; - } - - /** - * Converts a string from UTF-8 to the base encoding. The base encoding is set via this - * class' constructor. - * @param string $string - * @return string - */ - protected function fromUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - return $string; - } - - return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); - } - - /** - * Checks if a given string appears to be valid UTF-8 or not. - * - * @param string $string - * @return bool - */ - protected function isUtf8($string) - { - return ($string === '' || preg_match('/^./su', $string)); - } - - /** - * Encoding conversion helper which wraps iconv and mbstring where they exist or throws - * and exception where neither is available. - * - * @param string $string - * @param string $to - * @param array|string $from - * @throws Exception\RuntimeException - * @return string - */ - protected function convertEncoding($string, $to, $from) - { - if (function_exists('iconv')) { - $result = iconv($from, $to, $string); - } elseif (function_exists('mb_convert_encoding')) { - $result = mb_convert_encoding($string, $to, $from); - } else { - throw new Exception\RuntimeException( - get_class($this) - . ' requires either the iconv or mbstring extension to be installed' - . ' when escaping for non UTF-8 strings.' - ); - } - - if ($result === false) { - return ''; // return non-fatal blank string on encoding errors from users - } - return $result; - } -} diff --git a/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php b/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php deleted file mode 100644 index 7174796..0000000 --- a/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if ($file->getSize() / 1024 > $params[0]) { return false; @@ -173,6 +178,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // We know that our mimes list always has the first mime // start with `image` even when then are multiple accepted types. $type = \Config\Mimes::guessTypeFromExtension($file->getExtension()); @@ -216,6 +226,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getMimeType(), $params)) { return false; @@ -255,6 +270,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getExtension(), $params)) { return false; @@ -295,6 +315,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // Get Parameter sizes $allowedWidth = $params[0] ?? 0; $allowedHeight = $params[1] ?? 0; diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index 11d5ade..c8572b0 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -154,6 +154,20 @@ //-------------------------------------------------------------------- /** + * String of hexidecimal characters + * + * @param string $str + * + * @return boolean + */ + public function hex(string $str = null): bool + { + return ctype_xdigit($str); + } + + //-------------------------------------------------------------------- + + /** * Integer * * @param string $str diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index c27e045..fb09e7b 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -140,6 +140,47 @@ //-------------------------------------------------------------------- /** + * Checks the database to see if the given value exist. + * Can ignore records by field/value to filter (currently + * accept only one filter). + * + * Example: + * is_not_unique[table.field,where_field,where_value] + * is_not_unique[menu.id,active,1] + * + * @param string $str + * @param string $field + * @param array $data + * + * @return boolean + */ + public function is_not_unique(string $str = null, string $field, array $data): bool + { + // Grab any data for exclusion of a single row. + list($field, $where_field, $where_value) = array_pad(explode(',', $field), 3, null); + + // Break the table and field apart + sscanf($field, '%[^.].%[^.]', $table, $field); + + $db = Database::connect($data['DBGroup'] ?? null); + + $row = $db->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if (! empty($where_field) && ! empty($where_value)) + { + $row = $row->where($where_field, $where_value); + } + + return (bool) ($row->get() + ->getRow() !== null); + } + + //-------------------------------------------------------------------- + + /** * Value should be within an array of values * * @param string $value diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index c55e27c..959194c 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Validation/ValidationInterface.php b/system/Validation/ValidationInterface.php index ba4981f..cda21e0 100644 --- a/system/Validation/ValidationInterface.php +++ b/system/Validation/ValidationInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/View/Cell.php b/system/View/Cell.php index ff92f02..a7e79e9 100644 --- a/system/View/Cell.php +++ b/system/View/Cell.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -41,6 +41,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\View\Exceptions\ViewException; use ReflectionMethod; +use Config\Services; /** * Class Cell @@ -119,6 +120,11 @@ // Not cached - so grab it... $instance = new $class(); + if (method_exists($instance, 'initController')) + { + $instance->initController(Services::request(), Services::response(), Services::logger()); + } + if (! method_exists($instance, $method)) { throw ViewException::forInvalidCellMethod($class, $method); diff --git a/system/View/Filters.php b/system/View/Filters.php index f17c324..ad18ec8 100644 --- a/system/View/Filters.php +++ b/system/View/Filters.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/View/Parser.php b/system/View/Parser.php index d24dad5..1e7bc30 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -414,7 +414,10 @@ $str .= $out; } - $replace['#' . $match[0] . '#s'] = $str; + //Escape | character from filters as it's handled as OR in regex + $escaped_match = preg_replace('/(?sections[$sectionName] as $contents) + foreach ($this->sections[$sectionName] as $key => $contents) { echo $contents; + unset($this->sections[$sectionName][$key]); } } diff --git a/system/bootstrap.php b/system/bootstrap.php index 4694de4..33ab455 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/tests/_support/Models/ValidModel.php b/tests/_support/Models/ValidModel.php index 69842d8..dc9ec7c 100644 --- a/tests/_support/Models/ValidModel.php +++ b/tests/_support/Models/ValidModel.php @@ -22,7 +22,7 @@ 'required', 'min_length[3]', ], - 'token' => 'in_list[{id}]', + 'token' => 'permit_empty|in_list[{id}]', ]; protected $validationMessages = [