Skip to content

Commit 7420d0e

Browse files
adam-buckleyTinystep1Taliesin MillhouseDerekCrannafordD.Crannaford
authored
Merge develop into master (#171)
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 <alice.hutley@gmail.com> Co-authored-by: Taliesin Millhouse <taliesinwrmillhouse@gmail.com> Co-authored-by: Alice Hutley <55948506+Tinystep1@users.noreply.github.com> Co-authored-by: DerekCrannaford <43056286+DerekCrannaford@users.noreply.github.com> Co-authored-by: D.Crannaford <derek@2pisoftware.com> Co-authored-by: Adam Buckley <adam@2pisoftware.com> Co-authored-by: Dane Evans <dane@2pisoftware.com> Co-authored-by: Carsten Eckelmann <carsten@2pisoftware.com> Co-authored-by: Robert Lockerbie <robert@2pisoftware.com>
1 parent f4a4bf3 commit 7420d0e

507 files changed

Lines changed: 33574 additions & 5262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 110 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,143 +7,182 @@ on:
77
branches: [ develop, master ]
88

99
workflow_dispatch:
10+
env:
11+
TARGET_PHP: 8.1
12+
TARGET_MYSQL: 8
13+
DB_HOST: mysql-8
14+
DB_PORT: 3306
15+
DB_USERNAME: cmfive_test
16+
DB_PASSWORD: cmfive_test
17+
DB_DATABASE: cmfive_test
1018

1119
jobs:
1220
# Lint
13-
php-codesniffer:
14-
name: PHP CS
15-
runs-on: ubuntu-latest
21+
php-codesniffer74:
22+
name: PHP CS 7.4
23+
runs-on: ubuntu-22.04
1624
steps:
1725
- name: Get phpcs
1826
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
1927
- name: Codesniffer
2028
uses: pipeline-components/php-codesniffer@v0.12.3
2129
with:
2230
options: -s -p --colors --extensions=php --runtime-set testVersion 7.4
31+
php-codesniffer80:
32+
name: PHP CS 8.0
33+
runs-on: ubuntu-22.04
34+
steps:
35+
- name: Get phpcs
36+
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
37+
- name: Codesniffer
38+
uses: pipeline-components/php-codesniffer@v0.12.3
39+
with:
40+
options: -s -p --colors --extensions=php --runtime-set testVersion 8.0
41+
php-codesniffer81:
42+
name: PHP CS 8.1
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- name: Get phpcs
46+
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
47+
- name: Codesniffer
48+
uses: pipeline-components/php-codesniffer@v0.12.3
49+
with:
50+
options: -s -p --colors --extensions=php --runtime-set testVersion 8.1
2351
# Test
2452
run_test:
2553
# Checkout Boilerplate
2654
name: Unit/Acceptance tests
27-
runs-on: ubuntu-latest
28-
needs: [ php-codesniffer ]
55+
runs-on: ubuntu-22.04
56+
needs: [ php-codesniffer74, php-codesniffer80, php-codesniffer81 ]
2957
steps:
30-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v3
3159
with:
3260
repository: '2pisoftware/cmfive-boilerplate'
33-
ref: 'master'
34-
35-
# Cache
36-
- name: Cache Python Virtual Environment
37-
uses: actions/cache@v2
38-
id: pip
39-
with:
40-
path: .build/setup/venv
41-
key: ${{ runner.os }}-pip-${{ hashFiles('.build/setup/requirements.txt') }}
42-
43-
- name: Cache cmfive Docker Image
44-
uses: actions/cache@v2
45-
id: cmfive-docker-image
46-
with:
47-
path: /tmp/docker-registry
48-
key: docker-registry-${{ hashFiles('.build/environment/test/config/docker/Dockerfile.template') }}
61+
ref: 'feature/PHP8.1'
4962

50-
# Pre-requsites Prepare Runtime
51-
- name: Provision Python Virtual Environment
52-
if: steps.pip.outputs.cache-hit != 'true'
53-
run: |
54-
cd .build/setup;
55-
python3 -m venv venv;
56-
source venv/bin/activate;
57-
pip install -r requirements.txt;
58-
59-
- name: Prepare cmfive Test Environment
60-
run: |
61-
cd .build/setup;
62-
source venv/bin/activate;
63-
python install.py prime-environment test
64-
65-
- name: Prepare Docker Registry
66-
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
67-
68-
- name: Build and Push Image to Docker Registry
69-
if: steps.cmfive-docker-image.outputs.cache-hit != 'true'
70-
run: |
71-
docker build ./.build/environment/test/ -t cmfive --cache-from=localhost:5000/cmfive;
72-
docker tag cmfive localhost:5000/cmfive && docker push localhost:5000/cmfive || true;
73-
74-
- name: Pull Image from Docker Registry
75-
run: docker pull localhost:5000/cmfive || true
76-
77-
# Pre-requsites Prepare Cmfive Environment
63+
# Pre-requisites Prepare Cmfive Environment
7864
- name: Setup cmfive Test Environment
7965
run: |
80-
echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
81-
cd .build/setup;
82-
source venv/bin/activate;
83-
python install.py --verbose debug provision-test --cmfive_core_ref ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
66+
cp .codepipeline/test_agent/configs/test_agent-config.php config.php
67+
68+
docker-compose -f test_agent-compose.yml up --build -d
69+
sleep 5
70+
docker ps
71+
docker exec -t nginx-php8.1 bash -c "chmod -R 777 ./*"
72+
docker exec -t nginx-php8.1 bash -c "rm -rf ./system && ln -s ./composer/vendor/2pisoftware/cmfive-core/system ./system"
73+
74+
echo CoreInstall
75+
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/}}"
76+
77+
echo DBCreate
78+
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;\""
79+
80+
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
81+
8482
docker start selenium314;
85-
83+
docker ps
8684
- name: Inject configs into cmfive Test Environment
8785
run: |
88-
echo "Config::set('report.database', ['hostname' => 'mysql-5.7', 'username' => 'cmfive_test', 'password' => 'cmfive_test', 'database' => 'cmfive_test', 'driver' => 'mysql']);" >> config.php;
89-
echo "Config::set('core_template.foundation.reveal.animation_speed', 0);" >> config.php;
90-
echo "Config::set('core_template.foundation.reveal.animation', 'none');" >> config.php;
91-
92-
- name: Prepare cmfive Test Database
93-
run: docker exec nginx-php7.4 bash -c "php cmfive.php testDB setup; exit \$?";
86+
echo "Inheriting test_agent config from PIPELINE"
87+
echo 'Config::append("tests", ["testrunner" => "ENABLED"]);' >> config.php
9488
89+
- name: Prepare cmfive Test Backend
90+
run: |
91+
docker exec nginx-php8.1 bash -c "cd ./test/ && sh ./.install/install.sh && chmod -R 777 /var/www/html/test/Codeception/tests"
92+
93+
- name: Apply cmfive Test Config to Core install
94+
run: |
95+
echo SeedingCmfive
96+
docker exec nginx-php8.1 bash -c "cat config.php"
97+
# docker exec -t nginx-php8.1 bash -c "php cmfive.php install core ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
98+
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"
99+
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"
100+
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 admin@example.com admin admin"
101+
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
102+
103+
- name: Prepare cmfive Test DB
104+
run: |
105+
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 \$?";
106+
107+
# Build new layout
108+
- uses: actions/setup-node@v3
109+
with:
110+
node-version: 14
111+
112+
- name: Build new designs
113+
run: |
114+
docker exec -t nginx-php8.1 bash -c "chmod -R 777 system/templates/base"
115+
cd system/templates/base
116+
npm i
117+
npm run prod
118+
95119
# Run Unit Tests
96120
- name: "Run unit tests"
97121
run: |
98-
docker exec nginx-php7.4 bash -c "php cmfive.php tests unit all; exit \$?"
122+
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 \$?"
99123
if [ $? -gt 0 ]; then
100124
echo "Admin module tests failed"
101125
fi
102126
103127
# Run Acceptance Tests
128+
- name: "Confirm Codeception setup"
129+
run: |
130+
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"
104131
- name: "Run admin module tests"
105132
run: |
106-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module admin silent; exit \$?"
133+
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 \$?"
107134
if [ $? -gt 0 ]; then
108135
echo "Admin module tests failed"
109136
fi
110137
- name: "Run channels module tests"
111138
run: |
112-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module channels silent; exit \$?"
139+
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 \$?"
113140
if [ $? -gt 0 ]; then
114141
echo "Channels module tests failed"
115142
fi
116-
- name: "Run inbox module tests"
143+
- name: "Run form module tests"
117144
run: |
118-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module inbox silent; exit \$?"
145+
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 \$?"
119146
if [ $? -gt 0 ]; then
120-
echo "Inbox module tests failed"
147+
echo "Form module tests failed"
121148
fi
149+
# - name: "Run inbox module tests"
150+
# run: |
151+
# 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 \$?"
152+
# if [ $? -gt 0 ]; then
153+
# echo "Inbox module tests failed"
154+
# fi
122155
- name: "Run report module tests"
123156
run: |
124-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module report silent; exit \$?"
157+
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 \$?"
125158
if [ $? -gt 0 ]; then
126159
echo "Report module tests failed"
127160
fi
128161
- name: "Run tag module tests"
129162
run: |
130-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module tag silent; exit \$?"
163+
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 \$?"
131164
if [ $? -gt 0 ]; then
132165
echo "Tag module tests failed"
133166
fi
134167
- name: "Run task module tests"
135168
run: |
136-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module task silent; exit \$?"
169+
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 \$?"
137170
if [ $? -gt 0 ]; then
138171
echo "Task module tests failed"
139172
fi
140173
- name: "Run timelog module tests"
141174
run: |
142-
docker exec nginx-php7.4 bash -c "php cmfive.php tests module timelog silent; exit \$?"
175+
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 \$?"
143176
if [ $? -gt 0 ]; then
144177
echo "Timelog module tests failed"
145178
fi
146179
180+
- name: Stop containers
181+
# the containers should be stopped regardless of
182+
# the test result
183+
if: always()
184+
run: docker-compose down
185+
147186
# Store Test Results
148187
- name: Test results
149188
if: ${{ failure() }} || ${{ success() }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cmfive
1+
# 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)
22

33
## The core code base for Cmfive
44

system/classes/AspectModifiable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function insert()
3838
$mo->table_name = $this->object->getDbTableName();
3939
$mo->object_id = $this->object->id;
4040
$mo->dt_created = time();
41-
$user = $mo->w->Auth->user();
41+
$user = AuthService::getInstance($mo->w)->user();
4242
$mo->creator_id = (!empty($user->id) ? $user->id : 0);
4343
$mo->insert();
4444
}
@@ -51,7 +51,7 @@ public function update()
5151
{
5252
if ($this->getMo()) {
5353
$this->_mo->dt_modified = time();
54-
$user = $this->_mo->w->Auth->user();
54+
$user = AuthService::getInstance($this->_mo->w)->user();
5555
$this->_mo->modifier_id = (!empty($user->id) ? $user->id : 0);
5656
$this->_mo->update();
5757
}
@@ -122,7 +122,7 @@ class ObjectModification extends DbObject
122122
public function getCreator()
123123
{
124124
if ($this->creator_id) {
125-
return $this->w->Auth->getUser($this->creator_id);
125+
return AuthService::getInstance($this->w)->getUser($this->creator_id);
126126
}
127127
}
128128

@@ -136,7 +136,7 @@ public function getCreator()
136136
public function getModifier()
137137
{
138138
if ($this->modifier_id) {
139-
return $this->w->Auth->getUser($this->modifier_id);
139+
return AuthService::getInstance($this->w)->getUser($this->modifier_id);
140140
}
141141
}
142142
}

system/classes/AspectSearchable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function insert($ignoreAdditional = true) {
5858
$io->class_name = get_class($this->object);
5959
$io->object_id = $this->object->id;
6060
$io->dt_created = time();
61-
$io->creator_id = ($io->Auth->loggedIn() ? $io->Auth->user()->id : 0);
61+
$io->creator_id = (AuthService::getInstance($this->object->w)->loggedIn() ? AuthService::getInstance($this->object->w)->user()->id : 0);
6262
$io->content = $this->object->getIndexContent($ignoreAdditional);
6363
$io->insert();
6464
}
@@ -81,7 +81,7 @@ function update($ignoreAdditional = true) {
8181
$this->insert($ignoreAdditional);
8282
} else {
8383
$this->_index->dt_modified = time();
84-
$this->_index->modifier_id = ($this->_index->w->Auth->loggedIn() ? $this->_index->w->Auth->user()->id : 0);
84+
$this->_index->modifier_id = (AuthService::getInstance($this->_index->w)->loggedIn() ? AuthService::getInstance($this->_index->w)->user()->id : 0);
8585

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

0 commit comments

Comments
 (0)