Migration Guide - PHP 5.5 to 8.4¶
error_reporting(E_ALL)¶
- set error reporting in
includes/load.inc.php - check and fix all errors in
ids_logs/___php_error.logwhile clicking through the page
Mysqli¶
includes/db/mysql4.class.php (use RVS or Reifen Ritter as example)
- use mysqli everywhere
- new method
escape_string- use this everywhere instead of
mysql_real_escape_string
- use this everywhere instead of
Encoding, Special Characters, Umlaute¶
Save all relevant files in utf-8 (language files, ...)
Search for this character to find errors: �
In VSCode:
- click on encoding in bottom right corner
open with encodingWestern Windows 1252(or whatever the current encoding is)- special characters should be displayed now
- click on encoding in bottom right corner
save with encodingUTF-8
Unused files¶
Remove all unused files (after checking if they are needed or called, both in files and db-templates)
Also check crontab -l to see if a file gets used there
- del_folder (check if any files in this folder are still required somewhere)
___sicherungfolder- with
___in front of them (not all of them, needs to be properly checked) - duplicate files with timestamps at the end
- packages that should be installed with composer instead
- unused mudules (in this case: admin folder and user management)
- language files of unsupported languages
Composer¶
- install composer
composer init(use composer.json in other projects as reference)composer requirefor the needed packages- add
require_once ("./vendor/autoload.php");inincludes/load.inc.php - remove package from file system and change calls to package
Git¶
Using Reifen Ritter as example
- copied the whole codebase with ftp
- created a lokal git repository with
git init - created and commited a
.gitignorebased on an existing shop - created a backup branch to preserve the original state of the code.
- worked locally
- create a git repository on the website
- set local remote to this repository
remote add origin git@gitlab.com:<repo.git>
- push the main branch (maybe
-fis needed if remote main is not empty)git push origin main
- push the backup branch
git checkout backupgit push origin backup
If the .gitignore was changed later and the project needs to be updated accordingly:
- remove all files from version control
git rm -r --cached .
- add only the needed ones according to the gitignore file
git add .- then commit and push
Deprecated and removed things¶
- casts
- use
(int)instead of(integer) - use
(bool)instead of(boolean) - use
(float)instead of(double)or(real)
- use
- variables inside of strings
$a['abc'];instead of"$a[abc]";- i used these regexes to find appearances
\[(?!\d+\])([A-Za-z0-9_-]+)\]"(\$[A-Za-z0-9_-]+\[(?!\d+\])[A-Za-z0-9_-]+\])"
- array calls to not set elements
- need to be checked with
issetor null coalescing operator:??
- need to be checked with
- optional parameters in functions need to be last in order
PHPMailer¶
- set correct encoding when sending mails
$mail->CharSet = 'UTF-8';$mail->Encoding = 'base64';
$mail->Usernameand$mail->Fromneed to be identical- remove unused cc mail adresses
Order files¶
After a successful order in the shop, the order gets put into the following file: system/daten/export/bestellungen.txt
(or test___bestellungen.txt if youe are using the test user)
There needs to be a specific encoding and spacing for them to work. Reifen Ritter Software uses the ANSI/Windows-1252 encoding.
Changes in scart.php:
- search for
fopen()on thebestellungen.txt - check for the variable $b_text
- all
strlen()called on this variable need to be changed tomb_strlen()
- all
- right before the
fopen()add this code, then use the correct variable infwrite():
$b_text2 = iconv("UTF-8", "ISO-8859-15", $b_text);
if ($b_text2 == "") {
$b_text2 = utf8_decode($b_text);
}
$fd = fopen($pfad, "a+");
fwrite($fd, $b_text2 . "\n");
fclose($fd);
GoLive¶
clone the repository into a new folder on the server
- test if the files created with an order placement, are in the correct format
- files are inside
system/daten/export/bestellungen.txt
- files are inside
- run
composer install - check if all files (the ones, excluded from version control) are there, if not, copy from existing project
- extids folder
- php.ini
- copy the entire
systemfolder from the current live systemreifenshop - set the live subdomain to php version 8.4
- rename
reifenshoptoreifenshop_backup - rename new repository to
reifenshop - test everything
- click through the shop
- check if the correct database gets used