Skip to content

Commit d17dbdd

Browse files
committed
Try to fix install
Signed-off-by: henmohr <henriquemohr@redes.ufsm.br>
1 parent 13c5cf0 commit d17dbdd

5 files changed

Lines changed: 546 additions & 4 deletions

File tree

.docker/php/scripts/entrypoint.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,29 @@ if [ ! -f "LICENSE.txt" ]; then
99
chown -R www-data:www-data .
1010
fi
1111

12+
# Fix SuiteCRM 8.4.0 bugs for PHP 8.3
13+
# Bug #1: Remove duplicate static variable in AOW_WorkFlow (line 644)
14+
if [ -f "public/legacy/modules/AOW_WorkFlow/aow_utils.php" ]; then
15+
if grep -q "static \$sfh" public/legacy/modules/AOW_WorkFlow/aow_utils.php | grep -c "static \$sfh" | grep -q "2"; then
16+
sed -i '644d' public/legacy/modules/AOW_WorkFlow/aow_utils.php
17+
echo "Fixed: Removed duplicate static variable in AOW_WorkFlow/aow_utils.php"
18+
fi
19+
fi
20+
21+
# Bug #2: Remove duplicate static variable in InlineEditing (line 294)
22+
if [ -f "public/legacy/include/InlineEditing/InlineEditing.php" ]; then
23+
if [ $(grep -c "static \$sfh" public/legacy/include/InlineEditing/InlineEditing.php) -eq 2 ]; then
24+
sed -i '294d' public/legacy/include/InlineEditing/InlineEditing.php
25+
echo "Fixed: Removed duplicate static variable in InlineEditing/InlineEditing.php"
26+
fi
27+
fi
28+
29+
# Bug #3: Fix incorrect RewriteBase in .htaccess
30+
if [ -f "public/legacy/.htaccess" ]; then
31+
if grep -q "RewriteBase localhostlegacy/" public/legacy/.htaccess; then
32+
sed -i 's|RewriteBase localhostlegacy/|RewriteBase /legacy/|' public/legacy/.htaccess
33+
echo "Fixed: Corrected RewriteBase in public/legacy/.htaccess"
34+
fi
35+
fi
36+
1237
apache2-foreground

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [Unreleased]
6+
7+
### Added
8+
- Automatic bug fixes in entrypoint script for SuiteCRM 8.4.0 PHP 8.3 compatibility
9+
- `install.sh` script for automated installation with bug fix verification
10+
- Comprehensive documentation in README.md
11+
- WARP.md file for AI-assisted development
12+
- Manual bug fix instructions for existing installations
13+
14+
### Fixed
15+
- **Bug #1**: Duplicate static variable `$sfh` in `public/legacy/modules/AOW_WorkFlow/aow_utils.php` (line 644)
16+
- Symptom: Database failure error on initial load
17+
- Fix: Remove line 644 containing duplicate declaration
18+
19+
- **Bug #2**: Duplicate static variable `$sfh` in `public/legacy/include/InlineEditing/InlineEditing.php` (line 294)
20+
- Symptom: "Error while fetching data" when trying to login or access GraphQL API
21+
- Fix: Remove line 294 containing duplicate declaration
22+
23+
- **Bug #3**: Incorrect RewriteBase in `public/legacy/.htaccess`
24+
- Symptom: 500 Internal Server Error when accessing legacy pages
25+
- Issue: RewriteBase set to `localhostlegacy/` instead of `/legacy/`
26+
- Fix: Correct the RewriteBase path to `/legacy/`
27+
28+
### Changed
29+
- Updated entrypoint script to automatically apply all bug fixes on container startup
30+
- Enhanced README with detailed installation instructions and troubleshooting guide
31+
- Improved documentation structure with Quick Start options
32+
33+
### Technical Details
34+
35+
All bug fixes are:
36+
- **Idempotent**: Safe to run multiple times without breaking already-fixed installations
37+
- **Automatic**: Applied during container startup via entrypoint script
38+
- **Verified**: The entrypoint script detects bugs before applying fixes
39+
40+
The fixes address PHP 8.3 compatibility issues in SuiteCRM 8.4.0 that cause:
41+
1. Fatal compile errors due to duplicate static variable declarations
42+
2. Apache configuration errors due to malformed RewriteBase directives
43+
44+
## [1.0.0] - Initial Release
45+
46+
### Features
47+
- Docker Compose setup for SuiteCRM 8.4.0
48+
- PHP 8.3 with Apache
49+
- MySQL database
50+
- Xdebug support
51+
- Automatic SuiteCRM download and setup
52+
- GitHub Actions CI/CD pipeline

README.md

Lines changed: 294 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,300 @@
1-
# SuiteCRM
2-
SuiteCRM with docker-compose
1+
# SuiteCRM Docker Development Environment
32

4-
## Setup
3+
Docker-based development environment for SuiteCRM 8.x with PHP 8.3, Apache, and MySQL.
54

6-
clone this repository and run:
5+
## Quick Start
76

7+
### Option 1: Automated Installation (Recommended)
8+
9+
1. Clone this repository:
10+
```bash
11+
git clone <repository-url>
12+
cd suitecrm-docker
13+
```
14+
15+
2. Run the installation script:
16+
```bash
17+
./install.sh
18+
```
19+
20+
The script will start the containers, verify bug fixes, and guide you through the installation.
21+
22+
### Option 2: Manual Installation
23+
24+
1. Clone this repository:
25+
```bash
26+
git clone <repository-url>
27+
cd suitecrm-docker
828
```
29+
30+
2. Start the containers:
31+
```bash
932
docker compose up -d
1033
```
34+
35+
**Note**: The entrypoint script automatically fixes known SuiteCRM 8.4.0 bugs on startup.
36+
37+
3. Complete the installation:
38+
```bash
39+
docker compose exec php bin/console suitecrm:app:install \
40+
-U root \
41+
-P root \
42+
-H mysql \
43+
-Z 3306 \
44+
-N root \
45+
-u admin \
46+
-p admin \
47+
-S localhost \
48+
-d no \
49+
-W true
50+
```
51+
52+
4. Access SuiteCRM at http://localhost
53+
- **Username**: admin
54+
- **Password**: admin
55+
56+
## Known Issues
57+
58+
### SuiteCRM 8.4.0 Bugs
59+
60+
SuiteCRM 8.4.0 contains multiple bugs when running on PHP 8.3:
61+
62+
**Bug #1: Duplicate Static Variable in AOW_WorkFlow**
63+
- **File**: `public/legacy/modules/AOW_WorkFlow/aow_utils.php`
64+
- **Issue**: Static variable `$sfh` is declared twice (lines 438 and 644)
65+
- **Error**: `Fatal Compile Error: Duplicate declaration of static variable $sfh`
66+
- **Symptoms**: Database failure error on initial load
67+
- **Fix**: Remove line 644
68+
69+
**Bug #2: Duplicate Static Variable in InlineEditing**
70+
- **File**: `public/legacy/include/InlineEditing/InlineEditing.php`
71+
- **Issue**: Static variable `$sfh` is declared twice (lines 146 and 294)
72+
- **Error**: `Fatal Compile Error: Duplicate declaration of static variable $sfh`
73+
- **Symptoms**: "Error while fetching data" when trying to login or access GraphQL API
74+
- **Fix**: Remove line 294
75+
76+
**Bug #3: Incorrect RewriteBase in .htaccess**
77+
- **File**: `public/legacy/.htaccess`
78+
- **Issue**: RewriteBase is set to `localhostlegacy/` instead of `/legacy/`
79+
- **Error**: `RewriteBase: argument is not a valid URL`
80+
- **Symptoms**: 500 Internal Server Error when accessing legacy pages
81+
- **Fix**: Correct the RewriteBase path
82+
83+
All three fixes are **automatically applied** by the entrypoint script when the container starts. The fixes are idempotent - they only run if the bugs are detected and won't break already-fixed installations.
84+
85+
### Manual Bug Fixes (For Existing Installations)
86+
87+
If you have an existing SuiteCRM installation that wasn't started with the updated entrypoint, you can manually apply the fixes:
88+
89+
```bash
90+
# Fix bug #1: Duplicate static variable in AOW_WorkFlow
91+
docker compose exec php sed -i '644d' public/legacy/modules/AOW_WorkFlow/aow_utils.php
92+
93+
# Fix bug #2: Duplicate static variable in InlineEditing
94+
docker compose exec php sed -i '294d' public/legacy/include/InlineEditing/InlineEditing.php
95+
96+
# Fix bug #3: Incorrect RewriteBase in .htaccess
97+
docker compose exec php sed -i 's|RewriteBase localhostlegacy/|RewriteBase /legacy/|' public/legacy/.htaccess
98+
99+
# Clear cache and restart
100+
docker compose exec php bash -c "rm -rf cache/prod/* public/legacy/cache/*"
101+
docker compose restart php
102+
```
103+
104+
### Installation Lock
105+
106+
If the installation fails or is interrupted, you may need to unlock the installer:
107+
```bash
108+
docker compose exec php sed -i "s/'installer_locked' => true/'installer_locked' => false/" public/legacy/config.php
109+
```
110+
111+
Then retry the installation command from step 4.
112+
113+
## Manual Installation via Console
114+
115+
To manually install or reinstall SuiteCRM:
116+
117+
```bash
118+
docker compose exec php bin/console suitecrm:app:install [options]
119+
```
120+
121+
### Installation Options
122+
123+
- `-U, --db_username`: Database username (default: root)
124+
- `-P, --db_password`: Database password (default: root)
125+
- `-H, --db_host`: Database host (default: mysql)
126+
- `-Z, --db_port`: Database port (default: 3306)
127+
- `-N, --db_name`: Database name (default: root)
128+
- `-u, --site_username`: Admin username
129+
- `-p, --site_password`: Admin password
130+
- `-S, --site_host`: Site host (default: localhost)
131+
- `-d, --demoData`: Install demo data (yes/no)
132+
- `-W, --sys_check_option`: Ignore system check warnings (true/false)
133+
134+
### Example Installation Command
135+
136+
```bash
137+
docker compose exec php bin/console suitecrm:app:install \
138+
--db_username=root \
139+
--db_password=root \
140+
--db_host=mysql \
141+
--db_port=3306 \
142+
--db_name=root \
143+
--site_username=admin \
144+
--site_password=MySecurePassword123 \
145+
--site_host=localhost \
146+
--demoData=no \
147+
--sys_check_option=true
148+
```
149+
150+
## Architecture
151+
152+
### Services
153+
154+
- **php**: PHP 8.3 with Apache and required SuiteCRM extensions
155+
- Port: 80
156+
- Volume: `./volumes/suitecrm``/var/www/html`
157+
- Xdebug pre-configured (disabled by default)
158+
159+
- **mysql**: MySQL database
160+
- Port: 3306
161+
- Root password: root
162+
- Database: root
163+
- Volume: `./volumes/mysql/data``/var/lib/mysql`
164+
165+
### Environment Variables
166+
167+
Create a `.env` file or set in `docker-compose.yml`:
168+
169+
- `VERSION_SUITECRM`: SuiteCRM version to download (default: v8.8.0)
170+
- `XDEBUG_CONFIG`: Xdebug configuration
171+
- `TZ`: Timezone (default: America/Sao_Paulo)
172+
173+
## Common Commands
174+
175+
### Container Management
176+
177+
```bash
178+
# Start services
179+
docker compose up -d
180+
181+
# Stop services
182+
docker compose down
183+
184+
# View logs
185+
docker compose logs -f php
186+
187+
# Rebuild PHP container
188+
docker compose build php
189+
190+
# Access PHP container shell
191+
docker compose exec php bash
192+
```
193+
194+
### Database Access
195+
196+
```bash
197+
# MySQL CLI
198+
docker compose exec mysql mysql -uroot -proot root
199+
200+
# External connection
201+
mysql -h localhost -P 3306 -u root -proot root
202+
```
203+
204+
### SuiteCRM Console
205+
206+
```bash
207+
# Run console commands
208+
docker compose exec php bin/console <command>
209+
210+
# Clear cache
211+
docker compose exec php bin/console cache:clear
212+
213+
# List all commands
214+
docker compose exec php bin/console list
215+
```
216+
217+
### Cache Management
218+
219+
```bash
220+
# Clear Symfony cache
221+
docker compose exec php bash -c "rm -rf cache/prod/*"
222+
223+
# Clear legacy SuiteCRM cache
224+
docker compose exec php bash -c "rm -rf public/legacy/cache/*"
225+
226+
# Restart PHP container
227+
docker compose restart php
228+
```
229+
230+
## Debugging
231+
232+
### Enable Xdebug
233+
234+
1. Edit `.docker/php/config/php.ini`:
235+
```ini
236+
xdebug.mode=debug
237+
```
238+
239+
2. Rebuild and restart:
240+
```bash
241+
docker compose build php
242+
docker compose up -d
243+
```
244+
245+
3. Configure your IDE to listen on port 9003
246+
247+
### View Logs
248+
249+
```bash
250+
# Application logs
251+
docker compose exec php cat logs/prod/prod.log
252+
253+
# Installation logs
254+
docker compose exec php cat logs/install.log
255+
256+
# Apache logs
257+
docker compose logs php
258+
```
259+
260+
## Troubleshooting
261+
262+
### Database Failure Error
263+
264+
If you see "Database failure. Please refer to suitecrm.log":
265+
266+
1. Check for the duplicate static variable bug (see Known Issues)
267+
2. Verify database connection:
268+
```bash
269+
docker compose exec php php -r "new PDO('mysql:host=mysql;port=3306;dbname=root', 'root', 'root'); echo 'OK';"
270+
```
271+
3. Clear cache and restart
272+
273+
### Reset Installation
274+
275+
To completely reset and reinstall:
276+
277+
```bash
278+
# Stop containers and remove volumes
279+
docker compose down -v
280+
281+
# Remove SuiteCRM files
282+
sudo rm -rf volumes/
283+
284+
# Start fresh
285+
docker compose up -d
286+
287+
# Apply bug fix and install
288+
# (Follow steps 3-4 from Quick Start)
289+
```
290+
291+
## CI/CD
292+
293+
GitHub Actions automatically builds and publishes the Docker image to `ghcr.io` on:
294+
- Pushes to main/master
295+
- Tag creation (v*)
296+
- Pull requests
297+
298+
## License
299+
300+
SuiteCRM is licensed under AGPLv3. See LICENSE.txt for details.

0 commit comments

Comments
 (0)