Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 upgrade #74

Merged
merged 18 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .docker/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM httpd:2.4.33-alpine
RUN apk update; \
apk upgrade;
COPY minimanager.apache.conf /usr/local/apache2/conf/minimanager.apache.conf
RUN echo "Include /usr/local/apache2/conf/minimanager.apache.conf" \
>> /usr/local/apache2/conf/httpd.conf
21 changes: 21 additions & 0 deletions .docker/apache/minimanager.apache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ServerName localhost

LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so

<VirtualHost *:80>
# Proxy .php requests to port 9000 of the php-fpm container
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/$1
DocumentRoot /var/www/html/
<Directory /var/www/html/>
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

# Send apache logs to stdout and stderr
CustomLog /proc/self/fd/1 common
ErrorLog /proc/self/fd/2
</VirtualHost>
40 changes: 40 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.2"
services:
php:
build: './php/'
networks:
- backend
volumes:
- ../:/var/www/html/
apache:
build: './apache/'
depends_on:
- php
- mysql
networks:
- frontend
- backend
ports:
- "8080:80"
volumes:
- ../:/var/www/html/
mysql:
image: mysql:5.6.40
command: --init-file /mysql/init.sql
ports:
- "3306:3306"
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/init.sql:/mysql/init.sql
networks:
- backend
environment:
- MYSQL_ROOT_PASSWORD=rootpassword

healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
frontend:
backend:
109 changes: 109 additions & 0 deletions .docker/mysql/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
CREATE DATABASE IF NOT EXISTS mmftc;
USE mmftc;
--
-- Table structure for table `mm_forum_posts`
--

DROP TABLE IF EXISTS `mm_forum_posts`;

CREATE TABLE `mm_forum_posts`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`authorid` bigint(20) unsigned NOT NULL DEFAULT '0',
`authorname` varchar(16) NOT NULL DEFAULT '',
`forum` bigint(20) unsigned NOT NULL DEFAULT '0',
`topic` bigint(20) unsigned NOT NULL DEFAULT '0',
`lastpost` bigint(20) unsigned NOT NULL DEFAULT '0',
`name` varchar(50) NOT NULL DEFAULT '',
`text` longtext,
`time` varchar(255) NOT NULL,
`annouced` tinyint(3) unsigned NOT NULL DEFAULT '0',
`sticked` tinyint(3) unsigned NOT NULL DEFAULT '0',
`closed` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

--
-- Dumping data for table `mm_forum_posts`
--

LOCK
TABLES `mm_forum_posts` WRITE;
/*!40000 ALTER TABLE `mm_forum_posts` DISABLE KEYS */;
INSERT INTO `mm_forum_posts`(`id`, `authorid`, `authorname`, `forum`, `topic`, `lastpost`, `name`, `text`, `time`,
`annouced`, `sticked`)
values (1, 0, 'miniManagerTeam', 1, 1, 1, 'Hello Admin!',
'[b]Hi[/b] !!:D<br /><br />If you are reading this, that means that you have [i]correctly[/i] installed this forum, XD<br /><br /><br /><br />So what\' s next?<br /><br />Edit [color=red]forum.conf.php[/color]<br /><br /><br /><br />And enjoy!<br /><br /><br /><br />Report bugs at [url=https://github.com/TrinityCore/minimanager/issues]MiniManager tracker[/url]<br /><br /><br /><br />Bye!<br /><br />miniManagerTeam','00/00/00 00:00:00',1,0);
/*!40000 ALTER TABLE `mm_forum_posts` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `mm_motd`
--

DROP TABLE IF EXISTS `mm_motd`;

CREATE TABLE `mm_motd` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
`realmid` int(11) NOT NULL,
`type` longtext NOT NULL,
`content` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='MOTD System';

--
-- Dumping data for table `mm_motd`
--

LOCK TABLES `mm_motd` WRITE;
/*!40000 ALTER TABLE `mm_motd` DISABLE KEYS */;
INSERT INTO `mm_motd` VALUES (1, 1, '02/05/10 14:29:07 Posted by: MiniManager Team', 'Hello Admin\r\n\r\nhelp supporting Minimanager\r\n\r\nhttps://github.com/TrinityCore/minimanager/issues\r\n\r\nif you found a bug or improved it,
please contribute\r\n\r\nor it will eventually stop development from lack of interrest from community ');
/*!40000 ALTER TABLE `mm_motd` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `mm_point_system_invites`
--

DROP TABLE IF EXISTS `mm_point_system_invites`;
CREATE TABLE `mm_point_system_invites` (
`entry` int(11) NOT NULL auto_increment,
`PlayersAccount` char(50) default NULL,
`InvitedBy` char(50) default NULL,
`InviterAccount` char(50) default NULL,
`Treated` int(1) NOT NULL default '0',
`Rewarded` int(1) NOT NULL default '0',
UNIQUE KEY `entry` (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `mm_account`
--

DROP TABLE IF EXISTS `mm_account`;
CREATE TABLE `mm_account` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(32) NOT NULL DEFAULT '',
`salt` binary(32),
`verifier` binary(32),
`email` text,
`joindate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_ip` varchar(30) NOT NULL DEFAULT '127.0.0.1',
`locked` tinyint(3) unsigned NOT NULL DEFAULT '0',
`expansion` tinyint(3) unsigned NOT NULL DEFAULT '0',
`authkey` varchar(40) DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Accounts pending verification';

DROP TABLE IF EXISTS `mm_password_resets`;
CREATE TABLE `mm_password_resets` (
`token` binary(32) not null,
`accountId` int(11) unsigned not null,
`oldsalt` binary(32),
`salt` binary(32),
`verifier` binary(32),
`time` bigint unsigned,
primary key (`token`)
);
7 changes: 7 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM php:8.0-fpm-alpine
RUN apk update \
apk upgrade;
RUN apk add --upgrade php8-gmp gmp-dev;

RUN docker-php-ext-install mysqli gmp;

1 change: 1 addition & 0 deletions .docker/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=php_gmp.so
9 changes: 9 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function dobackup()
$row[$j] = preg_replace("/\n/","\\n",$row[$j]);
if (isset($row[$j]))
{
if ($sql->field_type($acc_query,$j) == "int")
if ($sql->field_type($j,$acc_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down Expand Up @@ -550,7 +550,7 @@ function dobackup()

if (isset($row[$j]))
{
if ($sql->field_type($char_query,$j) == "int")
if ($sql->field_type($j,$char_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down
2 changes: 1 addition & 1 deletion footer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
//hide undefined variables in some cases (some errorpages for ex.)
if (!isset($debug))
error_reporting('E_NONE'); // fuck this, we need a real fix
error_reporting(0); // fuck this, we need a real fix

// level 1 debug prints total queries,
// so we would have to close these, or we can't have debug output
Expand Down
18 changes: 11 additions & 7 deletions libs/db_lib/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function connect($db_host, $db_username, $db_password, $db_name = NULL, $use_nam

if ($this->link_id){
if (!empty($use_names)) $this->query("SET NAMES '$use_names'");
} else die($lang_global['err_sql_conn_db']);
} else die($lang_global['err_sql_conn_db'] . " DB: {$db_name}");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to make it more clear which database is failing, since the default error language does not make it obvious, and there's several potential culprits

}

function db($db_name) {
Expand Down Expand Up @@ -93,11 +93,11 @@ function free_result($query_id = false){
return ($query_id) ? @mysqli_free_result($query_id) : false;
}

function field_type($query_id = 0,$field_offset){
function field_type($field_offset, $query_id = 0){
return false; //TODO
}

function field_name($query_id = 0,$field_offset){
function field_name($field_offset,$query_id = 0){
return false; //TODO
}

Expand All @@ -118,11 +118,11 @@ function close(){
global $tot_queries;
$tot_queries += $this->num_queries;
if ($this->link_id){
if ($this->query_result) @mysqli_free_result($this->query_result);
return @mysqli_close($this->link_id);
if ($this->query_result instanceof mysqli_result) mysqli_free_result($this->query_result);
return mysqli_close($this->link_id);
} else return false;
}

function start_transaction(){
return;
}
Expand All @@ -131,4 +131,8 @@ function end_transaction(){
return;
}
}
?>
?>




2 changes: 1 addition & 1 deletion libs/db_lib/sql_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function sql_table_dump ($dbhost, $dbuser, $dbpass, $database, $table, $construc
$row[$j] = addslashes($row[$j]);
$row[$j] = preg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) {
if ($sql_0->field_type($query,$j) == "int") fwrite($fp, "$row[$j]")or die (error($lang_backup['file_write_err']));
if ($sql_0->field_type($j,$query) == "int") fwrite($fp, "$row[$j]")or die (error($lang_backup['file_write_err']));
else fwrite($fp, "'$row[$j]'")or die (error($lang_backup['file_write_err']));
}else fwrite($fp, "''")or die (error($lang_backup['file_write_err']));
if ($j<($num_fields-1)) fwrite($fp, ",")or die (error($lang_backup['file_write_err']));
Expand Down
4 changes: 2 additions & 2 deletions user.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function backup_user()

if (isset($row[$j]))
{
if ($sql->field_type($acc_query,$j) == "int")
if ($sql->field_type($j,$acc_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down Expand Up @@ -600,7 +600,7 @@ function backup_user()

if (isset($row[$j]))
{
if ($sql->field_type($char_query,$j) == "int")
if ($sql->field_type($j,$char_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down