diff --git a/.gitattributes b/.gitattributes index f1ed82db1653..074fc2cccc8a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,15 +15,12 @@ contributing/ export-ignore .nojekyll export-ignore export-ignore CODE_OF_CONDUCT.md export-ignore CONTRIBUTING.md export-ignore -PULL_REQUEST_TEMPLATE.md export-ignore -stale.yml export-ignore -Vagrantfile.dist export-ignore # They don't want our test files tests/AutoReview/ export-ignore tests/system/ export-ignore utils/ export-ignore -depfile.yaml export-ignore +deptrac.yaml export-ignore rector.php export-ignore phpunit.xml.dist export-ignore phpstan-baseline.neon.dist export-ignore diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index b9917c01e62b..bf4146edd3df 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -39,7 +39,7 @@ jobs: - app - system - tests - - utils/Rector + - utils steps: - name: Checkout uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2306247740..17a336c0b59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,59 @@ # Changelog +## [v4.2.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.2) (2022-08-05) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.1...v4.2.2) + +### Breaking Changes +* fix: when running on CLI, two Request objects were used in the system by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6089 +* fix: Builder insert()/update() does not accept an object by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6216 +* fix: create table if not exists when indexes already exist by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6249 +* fix: page cache saves Response data before running after filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6282 +* fix: random_string('crypto') may return string less than $len or ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6334 + +### Fixed Bugs +* Fixed: BaseBuilder increment/decrement do not reset state after a query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6146 +* fix: SQLite3\Connection\getIndexData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6152 +* fix: `is_image` causes PHP 8.1 deprecated error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6157 +* fix: prepared query is executed when using QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6164 +* fix: Time::getAge() calculation by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6159 +* fix: Session cookies are sent twice with Ajax by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6167 +* fix: QueryBuilder breaks select when escape is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5118 +* fix: PHPDoc return type in ControllerTestTrait methods by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6168 +* fix: `$routes->group('/', ...)` creates the route `foo///bar` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6186 +* fix: use lang('HTTP.pageNotFound') on production 404 page by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6202 +* fix: BaseConnection may create dynamic property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6198 +* fix: Email SMTP may throw Uncaught ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6184 +* fix: CSP reportOnly behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6201 +* fix: lang() causes Error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6209 +* fix: multiple pagers with models do not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6211 +* fix: tweak empty line output of `spark db:table` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6215 +* fix: custom validation error is cleared when calling setRule() twice by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6241 +* Fix: Validation of fields with a leading asterisk. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6243 +* fix: Call to undefined method CodeIgniter\Pager\PagerRenderer::getDetails() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6251 +* fix: exceptionHandler may cause HTTPException: Unknown HTTP status code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6254 +* fix: invalid INSERT/DELETE query when Query Builder uses table alias by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5376 +* fix: Add db port entry into env file. by @nalakapws in https://github.com/codeigniter4/CodeIgniter4/pull/6250 +* fix: update `.gitattributes` by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6256 +* fix: format_number() can't be used on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6263 +* fix: add parameter checking for max_size by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6261 +* fix: route name is not displayed in Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6269 +* fix: `spark routes` shows 404 error when using regex by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6279 +* fix: Entity::hasChanged() returns wrong result to mapped property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6285 +* fix: unable to add more than one file to FileCollection constructor by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6291 +* fix: Security::derandomize() may cause hex2bin() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6292 +* fix: use getenv() instead of $_SERVER in detectEnvironment() by @fcosrno in https://github.com/codeigniter4/CodeIgniter4/pull/6257 +* fix: OCI8 uses deprecated Entity by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6323 +* fix: Parse error occurs before PHP version check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6327 +* fix: 404 page might display Exception message in production environment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6333 + +### Refactoring +* refactor: replace $e->getMessage() with $e in log_message() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6182 +* refactor: add CompleteDynamicPropertiesRector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6187 +* refactor: debug toolbar by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6272 +* refactor: Exception exit code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6286 +* chore: Remove Vagrant by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6314 +* refactor: CSRF protection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6320 + ## [v4.2.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.1) (2022-06-16) [Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.0...v4.2.1) diff --git a/Vagrantfile.dist b/Vagrantfile.dist deleted file mode 100644 index e85393ff8588..000000000000 --- a/Vagrantfile.dist +++ /dev/null @@ -1,203 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# https://github.com/hashicorp/vagrant/issues/9442#issuecomment-374785457 -unless Vagrant::DEFAULT_SERVER_URL.frozen? - Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com') -end - -Vagrant.configure("2") do |config| - # VM Box - config.vm.box = "ubuntu/bionic64" - # Automatic box update checking - config.vm.box_check_update = true - - # CodeIgniter virtual host - config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - # Code Coverage virtual host - config.vm.network "forwarded_port", guest: 81, host: 8081, host_ip: "127.0.0.1" - # User Guide virtual host - config.vm.network "forwarded_port", guest: 82, host: 8082, host_ip: "127.0.0.1" - # MySQL server - #config.vm.network "forwarded_port", guest: 3306, host: 3307, host_ip: "127.0.0.1" - # PostgreSQL server - #config.vm.network "forwarded_port", guest: 5432, host: 5433, host_ip: "127.0.0.1" - # Memcached server - #config.vm.network "forwarded_port", guest: 11211, host: 11212, host_ip: "127.0.0.1" - # Redis server - #config.vm.network "forwarded_port", guest: 6379, host: 6380, host_ip: "127.0.0.1" - - # Add "192.168.10.10 ${VIRTUALHOST}" in your host file to access by domain - #config.vm.network "private_network", ip: "192.168.10.10" - - # Same path set in the $CODEIGNITER_PATH Provision - # "virtualbox" type allow auto-sync host to guest and guest to host - # but chmod does not work... tests will fail. - # Default rsync__args except "--copy-links", to allow phpunit correctly works by symlink - config.vm.synced_folder ".", "/var/www/codeigniter", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z"] - - # Provider-specific configuration - config.vm.provider "virtualbox" do |vb| - # Display the VirtualBox GUI when booting the machine - vb.gui = false - # Customize the amount of memory on the VM: - vb.memory = "1024" - end - - # Provision - config.vm.provision "shell", inline: <<-SHELL - MYSQL_ROOT_PASS="password" - PGSQL_ROOT_PASS="password" - VIRTUALHOST="localhost" - CODEIGNITER_PATH="/var/www/codeigniter" - PHP_VERSION=7.4 - PGSQL_VERSION=10 - #APT_PROXY="192.168.10.1:3142" - - grep -q "127.0.0.1 ${VIRTUALHOST}" /etc/hosts || echo "127.0.0.1 ${VIRTUALHOST}" >> /etc/hosts - - # Creates a swap file if necessary - RAM=`awk '/MemTotal/ {print $2}' /proc/meminfo` - if [ $RAM -lt 1000000 ] && [ ! -f /swap/swapfile ]; then - echo "================================================================================" - echo "Adding swap" - echo "================================================================================" - echo "This process may take a few minutes. Please wait..." - mkdir /swap - dd if=/dev/zero of=/swap/swapfile bs=1024 count=1000000 - chmod 600 /swap/swapfile - mkswap /swap/swapfile - swapon /swap/swapfile - echo "/swap/swapfile swap swap defaults 0 0" >> /etc/fstab - echo "Done." - fi - - # Prepare to use APT Proxy - if [ ! -z $APT_PROXY ]; then - if [ ! -f /etc/apt/sources.list-origin ]; then - cp /etc/apt/sources.list /etc/apt/sources.list-origin - fi - sed -i "s/archive.ubuntu.com/${APT_PROXY}/" /etc/apt/sources.list - sed -i "s/security.ubuntu.com/${APT_PROXY}/" /etc/apt/sources.list - fi - - export DEBIAN_FRONTEND=noninteractive - - echo "================================================================================" - echo "Updating and Installing Required Packages" - echo "================================================================================" - - add-apt-repository ppa:ondrej/php - - apt-get update - - debconf-set-selections <<< "mysql-server mysql-server/root_password password ${MYSQL_ROOT_PASS}" - debconf-set-selections <<< "mysql-server mysql-server/root_password_again password ${MYSQL_ROOT_PASS}" - - apt-get install -y \ - php$PHP_VERSION apache2 composer \ - php-intl php-mbstring php-xml php-zip php-xdebug \ - php-mysql mysql-server mysql-client \ - php-pgsql postgresql-$PGSQL_VERSION \ - php-sqlite3 sqlite3 \ - php-memcached memcached \ - php-redis redis-server \ - php-curl curl \ - php-gd php-imagick \ - python-pip - - pip install sphinx sphinxcontrib-phpdomain - - apt-get autoclean - - echo "================================================================================" - echo "Preparing User Guide" - echo "================================================================================" - - cd "${CODEIGNITER_PATH}/user_guide_src/cilexer" - python setup.py install - cd .. - make html - - echo "================================================================================" - echo "Configuring Databases" - echo "================================================================================" - - sed -i "s/^bind-address/#bind-address/" /etc/mysql/mysql.conf.d/mysqld.cnf - mysql -e "CREATE DATABASE IF NOT EXISTS codeigniter COLLATE 'utf8_general_ci'; - UPDATE mysql.user SET Host='%' WHERE user='root'; - GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; - FLUSH PRIVILEGES;" -uroot -p$MYSQL_ROOT_PASS - systemctl restart mysql - - sed -i "s/^#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/$PGSQL_VERSION/main/postgresql.conf - grep -q "host all root all md5" /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf || echo "host all root all md5" >> /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf - sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname='root'" | grep -q 1 || sudo -u postgres psql -c "CREATE ROLE root WITH SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN" - sudo -u postgres psql -c "ALTER ROLE root WITH PASSWORD '${PGSQL_ROOT_PASS}'" - sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='codeigniter'" | grep -q 1 ||sudo -u postgres psql -c "CREATE DATABASE codeigniter" - sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE codeigniter TO root" - systemctl restart postgresql - - echo "================================================================================" - echo "Configuring Memcached and Redis" - echo "================================================================================" - - sed -i "s/^bind 127.0.0.1/#bind 127.0.0.1/" /etc/redis/redis.conf - sed -i "s/^protected-mode yes/protected-mode no/" /etc/redis/redis.conf - sed -i "s/^-l 127.0.0.1/#-l 127.0.0.1/" /etc/memcached.conf - systemctl restart redis - systemctl restart memcached - - echo "================================================================================" - echo "Configuring Virtual Hosts" - echo "================================================================================" - - mkdir -p "${CODEIGNITER_PATH}/build/coverage-html" - mkdir -p "${CODEIGNITER_PATH}/public" - mkdir -p "${CODEIGNITER_PATH}/user_guide_src/build/html" - mkdir -p "${CODEIGNITER_PATH}/writable/apache" - chown -R vagrant:vagrant $CODEIGNITER_PATH - - # Creates a symlink in the user home - if [ ! -d /home/vagrant/codeigniter ]; then - ln -s $CODEIGNITER_PATH /home/vagrant/codeigniter - fi - - sed -i "s/APACHE_RUN_USER=www-data/APACHE_RUN_USER=vagrant/" /etc/apache2/envvars - sed -i "s/APACHE_RUN_GROUP=www-data/APACHE_RUN_GROUP=vagrant/" /etc/apache2/envvars - grep -q "Listen 81" /etc/apache2/ports.conf || sed -i "s/^Listen 80/Listen 80\\nListen 81\\nListen 82/" /etc/apache2/ports.conf - sed -i "s/^display_errors = Off/display_errors = On/" /etc/php/7.4/apache2/php.ini - sed -i "s/^display_startup_errors = Off/display_startup_errors = On/" /etc/php/7.4/apache2/php.ini - - echo "ServerName ${VIRTUALHOST} - - DirectoryIndex index.html index.php - Options All - AllowOverride All - - - ServerAdmin vagrant@localhost - DocumentRoot ${CODEIGNITER_PATH}/public - ErrorLog ${CODEIGNITER_PATH}/writable/apache/error.log - CustomLog ${CODEIGNITER_PATH}/writable/apache/custom.log combined - - - DocumentRoot ${CODEIGNITER_PATH}/build/coverage-html - - - DocumentRoot ${CODEIGNITER_PATH}/user_guide_src/build/html - -" > /etc/apache2/sites-available/codeigniter.conf - - a2enmod rewrite - a2dissite 000-default.conf - a2ensite codeigniter.conf - systemctl restart apache2 - - echo "================================================================================" - echo "Services Status" - echo "================================================================================" - service --status-all - - SHELL -end diff --git a/admin/RELEASE.md b/admin/RELEASE.md index dc51ca3c9b07..47e553e6d2e0 100644 --- a/admin/RELEASE.md +++ b/admin/RELEASE.md @@ -24,6 +24,10 @@ Copy the resulting content into **CHANGELOG.md** and adjust the format to match * Work off direct clones of the repos so the release branches persist for a time * Clone both **codeigniter4/CodeIgniter4** and **codeigniter4/userguide** and resolve any necessary PRs +```console +git clone git@github.com:codeigniter4/CodeIgniter4.git +git clone git@github.com:codeigniter4/userguide.git +``` * Vet the **admin/** folders for any removed hidden files (Action deploy scripts *do not remove these*) ## CodeIgniter4 @@ -40,25 +44,33 @@ Copy the resulting content into **CHANGELOG.md** and adjust the format to match * Create **user_guide_src/source/installation/upgrade_{ver}.rst**, fill in the "All Changes" section, and add it to **upgrading.rst** * Commit the changes with "Prep for 4.x.x release" and push to origin * Create a new PR from `release-4.x.x` to `develop`: - * Title: "Prep for 4.x.x release" - * Decription: "Updates changelog and version references for `4.x.x`." (plus checklist) + * Title: "Prep for 4.x.x release" + * Decription: "Updates changelog and version references for `4.x.x`." (plus checklist) * Let all tests run, then review and merge the PR * Create a new PR from `develop` to `master`: - * Title: "4.x.x Ready code" - * Description: blank + * Title: "4.x.x Ready code" + * Description: blank * Merge the PR then fast-forward `develop` to catch the merge commit +* Update the next minor upgrade branch `4.x` +```console +git fetch origin +git checkout 4.x +git merge origin/4.x +git merge origin/develop +git push origin HEAD +``` * Create a new Release: - * Version: "v4.x.x" - * Title: "CodeIgniter 4.x.x" - * Description: + * Version: "v4.x.x" + * Title: "CodeIgniter 4.x.x" + * Description: ``` -CodeIgniter 4.x.x release. +CodeIgniter 4.x.x release. See the changelog: https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md ``` * Watch for the "Deploy Framework" Action to make sure **framework** and **appstarter** get updated * Run the following commands to install and test AppStarter and verify the new version: -```bash +```console composer create-project codeigniter4/appstarter release-test cd release-test composer test && composer info codeigniter4/framework @@ -66,32 +78,14 @@ composer test && composer info codeigniter4/framework ## User Guide -> See "Sphinx Installation" below if you run into issues during `make` - -* Still in the **CodeIgniter4** repo enter the **user_guide_src** directory -* Clear out any old build files: `rm -rf build/` -* Build the HTML version of the User Guide: `make html` -* Build the ePub version of the User Guide: `make epub` -* Switch to the **userguide** repo and create a new branch `release-4.x.x` -* Replace **docs/** with **CodeIgniter4/user_guide_src/build/html** -* Ensure the file **docs/.nojekyll** exists or GitHub Pages will ignore folders with an underscore prefix -* Copy **CodeIgniter4/user_guide_src/build/epub/CodeIgniter.epub** to **./CodeIgniter4.x.x.epub** -* Commit the changes with "Update for 4.x.x" and push to origin -* Create a new PR from `release-4.x.x` to `develop`: - * Title: "Update for 4.x.x" - * Description: blank -* Merge the PR -* Create a new Release: - * Version: "v4.x.x" - * Title: "CodeIgniter 4.x.x User Guide" - * Description: "CodeIgniter 4.x.x User Guide" -* Watch for the "github pages" Environment to make sure the deployment succeeds +**This is now handled by GitHub Actions!** -### Website +Verify that the Actions succeeded: +* "Deploy User Guide", this repo +* "Deploy Production", UG repo +* "pages-build-deployment", both repos -The User Guide website should update itself via the deploy GitHub Action. Should this fail -the server must be updated manually. See repo and hosting details in the deploy script -at the User Guide repo. +See the legacy notes in Appendix for reference or to help manually recover from workflow failures. ## Announcement @@ -113,8 +107,33 @@ at the User Guide repo. You may need to install Sphinx and its dependencies prior to building the User Guide. This worked seamlessly on Ubuntu 20.04: -``` +```console sudo apt install python3-sphinx sudo pip3 install sphinxcontrib-phpdomain sudo pip3 install sphinx_rtd_theme ``` + +### Manual User Guide Process + +* Still in the **CodeIgniter4** repo enter the **user_guide_src** directory +* Clear out any old build files: `rm -rf build/` +* Build the HTML version of the User Guide: `make html` +* Build the ePub version of the User Guide: `make epub` +* Switch to the **userguide** repo and create a new branch `release-4.x.x` +* Replace **docs/** with **CodeIgniter4/user_guide_src/build/html** +* Ensure the file **docs/.nojekyll** exists or GitHub Pages will ignore folders with an underscore prefix +* Copy **CodeIgniter4/user_guide_src/build/epub/CodeIgniter.epub** to **./CodeIgniter4.x.x.epub** +* Commit the changes with "Update for 4.x.x" and push to origin +* Create a new PR from `release-4.x.x` to `develop`: + * Title: "Update for 4.x.x" + * Description: blank +* Merge the PR +* Create a new Release: + * Version: "v4.x.x" + * Title: "CodeIgniter 4.x.x User Guide" + * Description: "CodeIgniter 4.x.x User Guide" +* Watch for the "github pages" Environment to make sure the deployment succeeds + +The User Guide website should update itself via the deploy GitHub Action. Should this fail +the server must be updated manually. See repo and hosting details in the deploy script +at the User Guide repo. diff --git a/admin/framework/.github/workflows/close-pull-request.yml b/admin/framework/.github/workflows/close-pull-request.yml new file mode 100644 index 000000000000..4e01f30f5138 --- /dev/null +++ b/admin/framework/.github/workflows/close-pull-request.yml @@ -0,0 +1,18 @@ +name: Close Pull Request + +on: + pull_request_target: + types: [opened] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Close PR with nice message + uses: superbrothers/close-pull-request@v3 + with: + comment: > + Thank you for your pull request. However, you have submitted your PR on a read-only + split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 + repository.

Thank you. diff --git a/admin/module/phpunit.xml.dist b/admin/module/phpunit.xml.dist index 39d1dd2dde54..60c32ae056e7 100644 --- a/admin/module/phpunit.xml.dist +++ b/admin/module/phpunit.xml.dist @@ -1,57 +1,57 @@ - - - ./src - - - ./src/Views - ./src/Config/Routes.php - - - - - - - - - - - ./tests - - - - - - - - - - - - - - - - - - + bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php" + backupGlobals="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnError="false" + stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + ./src + + + ./src/Views + ./src/Config/Routes.php + + + + + + + + + + + ./tests + + + + + + + + + + + + + + + + + + diff --git a/admin/module/tests/README.md b/admin/module/tests/README.md index 3c05eeae92e7..be12d4c954c4 100644 --- a/admin/module/tests/README.md +++ b/admin/module/tests/README.md @@ -1,62 +1,81 @@ # Running Module Tests -This is the quick-start to CodeIgniter testing. Its intent is to describe what -it takes to set up your module and get it ready to run unit tests. -It is not intended to be a full description of the test features that you can +This is the quick-start to CodeIgniter testing. Its intent is to describe what +it takes to set up your module and get it ready to run unit tests. +It is not intended to be a full description of the test features that you can use to test your module. Those details can be found in the documentation. ## Resources + * [CodeIgniter 4 User Guide on Testing](https://codeigniter4.github.io/userguide/testing/index.html) -* [PHPUnit docs](https://phpunit.readthedocs.io/en/8.5/index.html) +* [PHPUnit docs](https://phpunit.de/documentation.html) +* [Any tutorials on Unit testing in CI4?](https://forum.codeigniter.com/showthread.php?tid=81830) ## Requirements -It is recommended to use the latest version of PHPUnit. At the time of this -writing we are running version 8.5.13. Support for this has been built into the -**composer.json** file that ships with CodeIgniter and can easily be installed +It is recommended to use the latest version of PHPUnit. At the time of this +writing we are running version 9.x. Support for this has been built into the +**composer.json** file that ships with CodeIgniter and can easily be installed via [Composer](https://getcomposer.org/) if you don't already have it installed globally. - > composer install +```console +> composer install +``` -If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer. +If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer. - > ln -s ./vendor/bin/phpunit ./phpunit +```console +> ln -s ./vendor/bin/phpunit ./phpunit +``` -You also need to install [XDebug](https://xdebug.org/index.php) in order -for code coverage to be calculated successfully. +You also need to install [XDebug](https://xdebug.org/docs/install) in order +for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage. ## Setting Up -A number of the tests use a running database. -In order to set up the database edit the details for the `tests` group in -**phpunit.xml**. Make sure that you provide a database engine that is currently running -on your machine. More details on a test database setup are in the -*Docs>>Testing>>Testing Your Database* section of the documentation. +A number of the tests use a running database. +In order to set up the database edit the details for the `tests` group in +**phpunit.xml**. +Make sure that you provide a database engine that is currently running on your machine. +More details on a test database setup are in the +[Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html) section of the documentation. ## Running the tests The entire test suite can be run by simply typing one command-line command from the main directory. - > ./phpunit +```console +> ./phpunit +``` + +If you are using Windows, use the following command. + +```console +> vendor\bin\phpunit +``` -You can limit tests to those within a single test directory by specifying the -directory name after phpunit. +You can limit tests to those within a single test directory by specifying the +directory name after phpunit. - > ./phpunit app/Models +```console +> ./phpunit tests/Models +``` ## Generating Code Coverage -To generate coverage information, including HTML reports you can view in your browser, -you can use the following command: +To generate coverage information, including HTML reports you can view in your browser, +you can use the following command: - > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m +```console +> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m +``` -This runs all of the tests again collecting information about how many lines, -functions, and files are tested. It also reports the percentage of the code that is covered by tests. -It is collected in two formats: a simple text file that provides an overview as well -as a comprehensive collection of HTML files that show the status of every line of code in the project. +This runs all of the tests again collecting information about how many lines, +functions, and files are tested. It also reports the percentage of the code that is covered by tests. +It is collected in two formats: a simple text file that provides an overview as well +as a comprehensive collection of HTML files that show the status of every line of code in the project. -The text file can be found at **tests/coverage.txt**. +The text file can be found at **tests/coverage.txt**. The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser. ## PHPUnit XML Configuration @@ -67,7 +86,7 @@ do not have your own configuration file in the project root. The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` (which is git ignored), and to tailor it as you see fit. -For instance, you might wish to exclude database tests, or automatically generate +For instance, you might wish to exclude database tests, or automatically generate HTML code coverage reports. ## Test Cases diff --git a/admin/starter/.github/workflows/close-pull-request.yml b/admin/starter/.github/workflows/close-pull-request.yml new file mode 100644 index 000000000000..4e01f30f5138 --- /dev/null +++ b/admin/starter/.github/workflows/close-pull-request.yml @@ -0,0 +1,18 @@ +name: Close Pull Request + +on: + pull_request_target: + types: [opened] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Close PR with nice message + uses: superbrothers/close-pull-request@v3 + with: + comment: > + Thank you for your pull request. However, you have submitted your PR on a read-only + split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 + repository.

Thank you. diff --git a/admin/starter/app/Config/Paths.php b/admin/starter/app/Config/Paths.php index d97bbb35a820..3ff97302bc41 100644 --- a/admin/starter/app/Config/Paths.php +++ b/admin/starter/app/Config/Paths.php @@ -34,8 +34,8 @@ class Paths * * If you want this front controller to use a different "app" * folder than the default one you can set its name here. The folder - * can also be renamed or relocated anywhere on your getServer. If - * you do, use a full getServer path. + * can also be renamed or relocated anywhere on your server. If + * you do, use a full server path. * * @see http://codeigniter.com/user_guide/general/managing_apps.html * diff --git a/admin/starter/phpunit.xml.dist b/admin/starter/phpunit.xml.dist index df6a6259f73e..62a473a733c4 100644 --- a/admin/starter/phpunit.xml.dist +++ b/admin/starter/phpunit.xml.dist @@ -1,57 +1,57 @@ - - - ./app - - - ./app/Views - ./app/Config/Routes.php - - - - - - - - - - - ./tests - - - - - - - - - - - - - - - - - - + bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php" + backupGlobals="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnError="false" + stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + ./app + + + ./app/Views + ./app/Config/Routes.php + + + + + + + + + + + ./tests + + + + + + + + + + + + + + + + + + diff --git a/admin/starter/preload.php b/admin/starter/preload.php index f36bacf3b0d1..ae935b0b9de2 100644 --- a/admin/starter/preload.php +++ b/admin/starter/preload.php @@ -16,7 +16,7 @@ * See https://www.php.net/manual/en/opcache.preloading.php * * How to Use: - * 1. Set Preload::$paths. + * 1. Set preload::$paths. * 2. Set opcache.preload in php.ini. * php.ini: * opcache.preload=/path/to/preload.php diff --git a/admin/starter/tests/README.md b/admin/starter/tests/README.md index 9d20661afecd..473d0f8c140e 100644 --- a/admin/starter/tests/README.md +++ b/admin/starter/tests/README.md @@ -1,72 +1,81 @@ # Running Application Tests -This is the quick-start to CodeIgniter testing. Its intent is to describe what -it takes to set up your application and get it ready to run unit tests. -It is not intended to be a full description of the test features that you can +This is the quick-start to CodeIgniter testing. Its intent is to describe what +it takes to set up your application and get it ready to run unit tests. +It is not intended to be a full description of the test features that you can use to test your application. Those details can be found in the documentation. ## Resources * [CodeIgniter 4 User Guide on Testing](https://codeigniter4.github.io/userguide/testing/index.html) * [PHPUnit docs](https://phpunit.de/documentation.html) +* [Any tutorials on Unit testing in CI4?](https://forum.codeigniter.com/showthread.php?tid=81830) ## Requirements -It is recommended to use the latest version of PHPUnit. At the time of this -writing we are running version 9.x. Support for this has been built into the -**composer.json** file that ships with CodeIgniter and can easily be installed +It is recommended to use the latest version of PHPUnit. At the time of this +writing we are running version 9.x. Support for this has been built into the +**composer.json** file that ships with CodeIgniter and can easily be installed via [Composer](https://getcomposer.org/) if you don't already have it installed globally. - > composer install +```console +> composer install +``` -If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer. +If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer. - > ln -s ./vendor/bin/phpunit ./phpunit +```console +> ln -s ./vendor/bin/phpunit ./phpunit +``` -You also need to install [XDebug](https://xdebug.org/index.php) in order -for code coverage to be calculated successfully. +You also need to install [XDebug](https://xdebug.org/docs/install) in order +for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage. ## Setting Up -A number of the tests use a running database. -In order to set up the database edit the details for the `tests` group in -**app/Config/Database.php** or **phpunit.xml**. Make sure that you provide a database engine -that is currently running on your machine. More details on a test database setup are in the +A number of the tests use a running database. +In order to set up the database edit the details for the `tests` group in +**app/Config/Database.php** or **phpunit.xml**. +Make sure that you provide a database engine that is currently running on your machine. +More details on a test database setup are in the [Testing Your Database](https://codeigniter4.github.io/userguide/testing/database.html) section of the documentation. -If you want to run the tests without using live database you can -exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml** - -call it **phpunit.xml** - and comment out the named "database". This will make -the tests run quite a bit faster. - ## Running the tests The entire test suite can be run by simply typing one command-line command from the main directory. - > ./phpunit +```console +> ./phpunit +``` If you are using Windows, use the following command. - > vendor\bin\phpunit +```console +> vendor\bin\phpunit +``` -You can limit tests to those within a single test directory by specifying the -directory name after phpunit. +You can limit tests to those within a single test directory by specifying the +directory name after phpunit. - > ./phpunit app/Models +```console +> ./phpunit app/Models +``` ## Generating Code Coverage -To generate coverage information, including HTML reports you can view in your browser, -you can use the following command: +To generate coverage information, including HTML reports you can view in your browser, +you can use the following command: - > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m +```console +> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m +``` -This runs all of the tests again collecting information about how many lines, -functions, and files are tested. It also reports the percentage of the code that is covered by tests. -It is collected in two formats: a simple text file that provides an overview as well -as a comprehensive collection of HTML files that show the status of every line of code in the project. +This runs all of the tests again collecting information about how many lines, +functions, and files are tested. It also reports the percentage of the code that is covered by tests. +It is collected in two formats: a simple text file that provides an overview as well +as a comprehensive collection of HTML files that show the status of every line of code in the project. -The text file can be found at **tests/coverage.txt**. +The text file can be found at **tests/coverage.txt**. The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser. ## PHPUnit XML Configuration @@ -77,7 +86,7 @@ do not have your own configuration file in the project root. The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` (which is git ignored), and to tailor it as you see fit. -For instance, you might wish to exclude database tests, or automatically generate +For instance, you might wish to exclude database tests, or automatically generate HTML code coverage reports. ## Test Cases diff --git a/admin/userguide/.github/workflows/close-pull-request.yml b/admin/userguide/.github/workflows/close-pull-request.yml new file mode 100644 index 000000000000..4e01f30f5138 --- /dev/null +++ b/admin/userguide/.github/workflows/close-pull-request.yml @@ -0,0 +1,18 @@ +name: Close Pull Request + +on: + pull_request_target: + types: [opened] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Close PR with nice message + uses: superbrothers/close-pull-request@v3 + with: + comment: > + Thank you for your pull request. However, you have submitted your PR on a read-only + split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 + repository.

Thank you. diff --git a/app/Config/App.php b/app/Config/App.php index c6c716822756..1a5e562ddd30 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -44,7 +44,7 @@ class App extends BaseConfig * URI PROTOCOL * -------------------------------------------------------------------------- * - * This item determines which getServer global should be used to retrieve the + * This item determines which server global should be used to retrieve the * URI string. The default setting of 'REQUEST_URI' works for most servers. * If your links do not seem to work, try one of the other delicious flavors: * diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 0c1b53487cd9..47b92f832935 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -67,16 +67,16 @@ | http://tldp.org/LDP/abs/html/exitcodes.html | */ -defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors -defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error -defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error -defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found -defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class +defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors +defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error +defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error +defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found +defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member -defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input -defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error -defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code -defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code +defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input +defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error +defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code +defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code /** * @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead. diff --git a/app/Config/Logger.php b/app/Config/Logger.php index 406d9aaccc85..fe389d8a2078 100644 --- a/app/Config/Logger.php +++ b/app/Config/Logger.php @@ -60,7 +60,7 @@ class Logger extends BaseConfig * The logging system supports multiple actions to be taken when something * is logged. This is done by allowing for multiple Handlers, special classes * designed to write the log to their chosen destinations, whether that is - * a file on the getServer, a cloud-based service, or even taking actions such + * a file on the server, a cloud-based service, or even taking actions such * as emailing the dev team. * * Each handler is defined by the class name used for that handler, and it diff --git a/app/Config/Paths.php b/app/Config/Paths.php index f701b7570507..1b313a7f2a45 100644 --- a/app/Config/Paths.php +++ b/app/Config/Paths.php @@ -34,8 +34,8 @@ class Paths * * If you want this front controller to use a different "app" * folder than the default one you can set its name here. The folder - * can also be renamed or relocated anywhere on your getServer. If - * you do, use a full getServer path. + * can also be renamed or relocated anywhere on your server. If + * you do, use a full server path. * * @see http://codeigniter.com/user_guide/general/managing_apps.html * diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php index f81717fdd0f5..5ba9f8add075 100644 --- a/app/Views/errors/html/error_404.php +++ b/app/Views/errors/html/error_404.php @@ -73,7 +73,7 @@

404 - File Not Found

- + Sorry! Cannot seem to find the page you were looking for. diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index c66a9615c6be..c5325b57a813 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -200,9 +200,10 @@