Skip to content

Commit

Permalink
Merge develop into master (#171)
Browse files Browse the repository at this point in the history
PHP 8.1 changes

* ! Removed magic __get functions from Web, DbObject and DbService
* ! Removed request() from Web in lieu of the Request static class
* ! Also removed cmp_weights(), sendFile(), service(), _callPreListeners() and _callPostListeners() from Web
* Commented out CachedTemplate in Web, expected to be removed in future version
* Added support for code sniffing in Github actions over multiple PHP versions
* Migrated all usages of magic $w::__get method to the proper DbService::getInstance($w) function
* ! Removed unused shorthand _tn and _cn functions from DbObject
* ! Removed snake_case functions in lieu of the matching camelCase counterparts from DbPDO
* ! Removed setMissingResponse() from JsonResponse
* ! Removed getFileExtension(), lookupForSelect() , getStateSelectArray(), formatMoney(), returncorrectdates(), AESencrypt() and AESdecrypt() from functions.php
* ! Updated FluentPDO to latest version
* ! Removed all Lookup functions from AdminService (use LookupService instead)
* Added missing functions to LookupService from point above
* Removed checkPassword() from User model
* Removed $update_salt flag from encryptPassword() function in User model
* Removed getNewMessages() from ChannelService
* Moved from Zend to Laminas (still Zend, just new name)
* Added ability for migrations run on CLI to print errors to screen
* Updated some composer dependencies to latest version
* Updated development Docker container to Ubuntu 20.04 LTS
* Fixed type bugs due to move to PHP 8.x
* Fixed static service instantiation for PHP 8.x
* Fixed some code formatting
* Started adding property types to Web
* Backwards breaking changes to cmfive core:

Potentially breaking changes:
* Updated FluentPDO to add support for PHP8.1

Notices:
* Removed user account creation hook listener in the Inbox module

Post test updates
* Corrected reference to DbPDO
* Tidied up some code that was commented
* Updated workflow to remove reliance on python set up scripts
* Updates to CI scripts

### General features/updates
* Added CountryService methods
* Added AdminService::getCountryWhere() method.
* Added missing returns to User::deleted() method.
* Added profile security vue component
* Added Request::array() method
* Added helper functions to Language model
* Added ability to hide application name on login
* Added better support for enabling/disabling help and search functionality
* Added support for filtering uploadings based on file extension (checks mimetype)
* Added country and language seed
* Added login attempt tracking with account lock
* Added password strength enforcement 
* Added automatic logout after inactivity
* Added customisable login field labels
* Added persistent banner for when mfa is required but user doesn't have it on
* Added MFA insight
* Added pagination to user list
* Added antivirus service
* Added support for test_mode banner
* Updated tests
* Updated .github/ci.yml
* Fixed History class doubling up some endpoints
* Fixed several typos.
* Fixed issue with memory usage of uploads
* Fixed issue with insights
* Fixed usage of deprecated sass compiler function
* Fixed issue with short login field size
* Fixed more issues from PHP 8.1 migration

### New design features
* Added ability to compile assets in project modules
* Added new base template designs
* Added dark mode
* Added data-link-target support
* Added dom update event bus,
* Added new Bootstrap html functions
* Added basic animation support
* Added support for multifile upload, inputs. Fix a bug with multiple attachments in FileService
* Added support for quill, added some helper functions
* Removed build artifacts, added multiselect support, changed identifier of Language to 3 letter code
* Added pagination styles, updated inputwithother
* Added form class support to html, updated alerts to be in line with bootstraps styles
* Added responsive table
* Added persistence of theme settings via new user setting feature
* Added 'dataCard' element
* Added splash overly for long processes
* Added support for bootstrap tooltips

* Various spot patches from 8.1 testing (#172)
* Fix: Patching From Module Observations (#173)

* Language migrations if NOTABLE exists vs importDB
* fixes for php8.1 and mysql8 migration
* Db column, (_Typo, strip_tags_STR
* Hide PolyFill dev logging
* Small fixes, null strings and wrong typing
* Some stray non-conditional STRPOS
* Conformed Stray ->log->

Co-authored-by: Alice <[email protected]>
Co-authored-by: Taliesin Millhouse <[email protected]>
Co-authored-by: Alice Hutley <[email protected]>
Co-authored-by: DerekCrannaford <[email protected]>
Co-authored-by: D.Crannaford <[email protected]>
Co-authored-by: Adam Buckley <[email protected]>
Co-authored-by: Dane Evans <[email protected]>
Co-authored-by: Carsten Eckelmann <[email protected]>
Co-authored-by: Robert Lockerbie <[email protected]>
  • Loading branch information
10 people authored Mar 30, 2023
1 parent f4a4bf3 commit 7420d0e
Show file tree
Hide file tree
Showing 507 changed files with 33,574 additions and 5,262 deletions.
181 changes: 110 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,143 +7,182 @@ on:
branches: [ develop, master ]

workflow_dispatch:
env:
TARGET_PHP: 8.1
TARGET_MYSQL: 8
DB_HOST: mysql-8
DB_PORT: 3306
DB_USERNAME: cmfive_test
DB_PASSWORD: cmfive_test
DB_DATABASE: cmfive_test

jobs:
# Lint
php-codesniffer:
name: PHP CS
runs-on: ubuntu-latest
php-codesniffer74:
name: PHP CS 7.4
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 7.4
php-codesniffer80:
name: PHP CS 8.0
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 8.0
php-codesniffer81:
name: PHP CS 8.1
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 8.1
# Test
run_test:
# Checkout Boilerplate
name: Unit/Acceptance tests
runs-on: ubuntu-latest
needs: [ php-codesniffer ]
runs-on: ubuntu-22.04
needs: [ php-codesniffer74, php-codesniffer80, php-codesniffer81 ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: '2pisoftware/cmfive-boilerplate'
ref: 'master'

# Cache
- name: Cache Python Virtual Environment
uses: actions/cache@v2
id: pip
with:
path: .build/setup/venv
key: ${{ runner.os }}-pip-${{ hashFiles('.build/setup/requirements.txt') }}

- name: Cache cmfive Docker Image
uses: actions/cache@v2
id: cmfive-docker-image
with:
path: /tmp/docker-registry
key: docker-registry-${{ hashFiles('.build/environment/test/config/docker/Dockerfile.template') }}
ref: 'feature/PHP8.1'

# Pre-requsites Prepare Runtime
- name: Provision Python Virtual Environment
if: steps.pip.outputs.cache-hit != 'true'
run: |
cd .build/setup;
python3 -m venv venv;
source venv/bin/activate;
pip install -r requirements.txt;
- name: Prepare cmfive Test Environment
run: |
cd .build/setup;
source venv/bin/activate;
python install.py prime-environment test
- name: Prepare Docker Registry
run: docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2 && npx wait-on tcp:5000

- name: Build and Push Image to Docker Registry
if: steps.cmfive-docker-image.outputs.cache-hit != 'true'
run: |
docker build ./.build/environment/test/ -t cmfive --cache-from=localhost:5000/cmfive;
docker tag cmfive localhost:5000/cmfive && docker push localhost:5000/cmfive || true;
- name: Pull Image from Docker Registry
run: docker pull localhost:5000/cmfive || true

# Pre-requsites Prepare Cmfive Environment
# Pre-requisites Prepare Cmfive Environment
- name: Setup cmfive Test Environment
run: |
echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
cd .build/setup;
source venv/bin/activate;
python install.py --verbose debug provision-test --cmfive_core_ref ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
cp .codepipeline/test_agent/configs/test_agent-config.php config.php
docker-compose -f test_agent-compose.yml up --build -d
sleep 5
docker ps
docker exec -t nginx-php8.1 bash -c "chmod -R 777 ./*"
docker exec -t nginx-php8.1 bash -c "rm -rf ./system && ln -s ./composer/vendor/2pisoftware/cmfive-core/system ./system"
echo CoreInstall
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php install core ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
echo DBCreate
docker exec -t mysql-8 bash -c "mysql -h 127.0.0.1 -u'root' -p'root' --execute \"CREATE DATABASE cmfive_test; CREATE USER cmfive_test@'%' IDENTIFIED BY 'cmfive_test'; GRANT ALL PRIVILEGES ON cmfive_test.* TO cmfive_test@'%'; GRANT PROCESS ON *.* TO cmfive_test@'%'; FLUSH PRIVILEGES;\""
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
docker start selenium314;
docker ps
- name: Inject configs into cmfive Test Environment
run: |
echo "Config::set('report.database', ['hostname' => 'mysql-5.7', 'username' => 'cmfive_test', 'password' => 'cmfive_test', 'database' => 'cmfive_test', 'driver' => 'mysql']);" >> config.php;
echo "Config::set('core_template.foundation.reveal.animation_speed', 0);" >> config.php;
echo "Config::set('core_template.foundation.reveal.animation', 'none');" >> config.php;
- name: Prepare cmfive Test Database
run: docker exec nginx-php7.4 bash -c "php cmfive.php testDB setup; exit \$?";
echo "Inheriting test_agent config from PIPELINE"
echo 'Config::append("tests", ["testrunner" => "ENABLED"]);' >> config.php
- name: Prepare cmfive Test Backend
run: |
docker exec nginx-php8.1 bash -c "cd ./test/ && sh ./.install/install.sh && chmod -R 777 /var/www/html/test/Codeception/tests"
- name: Apply cmfive Test Config to Core install
run: |
echo SeedingCmfive
docker exec nginx-php8.1 bash -c "cat config.php"
# docker exec -t nginx-php8.1 bash -c "php cmfive.php install core ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php seed encryption"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php install migrations"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php seed admin admin admin [email protected] admin admin"
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
- name: Prepare cmfive Test DB
run: |
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php testDB setup; exit \$?";
# Build new layout
- uses: actions/setup-node@v3
with:
node-version: 14

- name: Build new designs
run: |
docker exec -t nginx-php8.1 bash -c "chmod -R 777 system/templates/base"
cd system/templates/base
npm i
npm run prod
# Run Unit Tests
- name: "Run unit tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests unit all; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests unit all; exit \$?"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
# Run Acceptance Tests
- name: "Confirm Codeception setup"
run: |
docker exec nginx-php8.1 bash -c "ls -lah -R /var/www/html/test/Codeception/tests && cat /var/www/html/test/Codeception/*.yml && cat /var/www/html/test/Codeception/tests/*.yml"
- name: "Run admin module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module admin silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module admin silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
- name: "Run channels module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module channels silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module channels silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Channels module tests failed"
fi
- name: "Run inbox module tests"
- name: "Run form module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module inbox silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module form silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Inbox module tests failed"
echo "Form module tests failed"
fi
# - name: "Run inbox module tests"
# run: |
# docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module inbox silent; exit \$?"
# if [ $? -gt 0 ]; then
# echo "Inbox module tests failed"
# fi
- name: "Run report module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module report silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module report silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Report module tests failed"
fi
- name: "Run tag module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module tag silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module tag silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Tag module tests failed"
fi
- name: "Run task module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module task silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module task silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Task module tests failed"
fi
- name: "Run timelog module tests"
run: |
docker exec nginx-php7.4 bash -c "php cmfive.php tests module timelog silent; exit \$?"
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module timelog silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Timelog module tests failed"
fi
- name: Stop containers
# the containers should be stopped regardless of
# the test result
if: always()
run: docker-compose down

# Store Test Results
- name: Test results
if: ${{ failure() }} || ${{ success() }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cmfive
# Cmfive &nbsp;&nbsp;&nbsp;[![CI](https://github.com/2pisoftware/cmfive-core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/2pisoftware/cmfive-core/actions/workflows/ci.yml)

## The core code base for Cmfive

Expand Down
8 changes: 4 additions & 4 deletions system/classes/AspectModifiable.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function insert()
$mo->table_name = $this->object->getDbTableName();
$mo->object_id = $this->object->id;
$mo->dt_created = time();
$user = $mo->w->Auth->user();
$user = AuthService::getInstance($mo->w)->user();
$mo->creator_id = (!empty($user->id) ? $user->id : 0);
$mo->insert();
}
Expand All @@ -51,7 +51,7 @@ public function update()
{
if ($this->getMo()) {
$this->_mo->dt_modified = time();
$user = $this->_mo->w->Auth->user();
$user = AuthService::getInstance($this->_mo->w)->user();
$this->_mo->modifier_id = (!empty($user->id) ? $user->id : 0);
$this->_mo->update();
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class ObjectModification extends DbObject
public function getCreator()
{
if ($this->creator_id) {
return $this->w->Auth->getUser($this->creator_id);
return AuthService::getInstance($this->w)->getUser($this->creator_id);
}
}

Expand All @@ -136,7 +136,7 @@ public function getCreator()
public function getModifier()
{
if ($this->modifier_id) {
return $this->w->Auth->getUser($this->modifier_id);
return AuthService::getInstance($this->w)->getUser($this->modifier_id);
}
}
}
4 changes: 2 additions & 2 deletions system/classes/AspectSearchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function insert($ignoreAdditional = true) {
$io->class_name = get_class($this->object);
$io->object_id = $this->object->id;
$io->dt_created = time();
$io->creator_id = ($io->Auth->loggedIn() ? $io->Auth->user()->id : 0);
$io->creator_id = (AuthService::getInstance($this->object->w)->loggedIn() ? AuthService::getInstance($this->object->w)->user()->id : 0);
$io->content = $this->object->getIndexContent($ignoreAdditional);
$io->insert();
}
Expand All @@ -81,7 +81,7 @@ function update($ignoreAdditional = true) {
$this->insert($ignoreAdditional);
} else {
$this->_index->dt_modified = time();
$this->_index->modifier_id = ($this->_index->w->Auth->loggedIn() ? $this->_index->w->Auth->user()->id : 0);
$this->_index->modifier_id = (AuthService::getInstance($this->_index->w)->loggedIn() ? AuthService::getInstance($this->_index->w)->user()->id : 0);

$this->_index->content = $this->object->getIndexContent($ignoreAdditional);

Expand Down
Loading

0 comments on commit 7420d0e

Please sign in to comment.