Skip to content

[Ubiquity] Update to PHP 8 #6187

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

Merged
merged 4 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions frameworks/PHP/ubiquity/app/controllers/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Bench controller.
*/
class Cache extends \Ubiquity\controllers\Controller {
use DbTrait;

protected $cache;

Expand All @@ -23,7 +22,7 @@ public function index() {}

public function cachedquery($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
while ($count --) {
$worlds[] = ($this->cache->fetch('models\\CachedWorld', \mt_rand(1, 10000)))->_rest;
}
Expand Down
6 changes: 2 additions & 4 deletions frameworks/PHP/ubiquity/app/controllers/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

use Ubiquity\orm\SDAO;
use models\World;
use controllers\utils\DbTrait;

/**
* Bench controller.
*/
class Db extends \Ubiquity\controllers\Controller {
use DbTrait;

public function __construct() {}

Expand All @@ -26,7 +24,7 @@ public function index() {

public function query($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
for ($i = 0; $i < $count; ++ $i) {
$worlds[] = (SDAO::getById(World::class, [
'id' => \mt_rand(1, 10000)
Expand All @@ -38,7 +36,7 @@ public function query($queries = 1) {
public function update($queries = 1) {
$worlds = [];

$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
$ids = $this->getUniqueRandomNumbers($count);
foreach ($ids as $id) {
$world = SDAO::getById(World::class, [
Expand Down
2 changes: 1 addition & 1 deletion frameworks/PHP/ubiquity/app/controllers/DbMongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function warmup() {

public function update($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
$ids = $this->getUniqueRandomNumbers($count);
foreach ($ids as $id) {
$world = self::$pDao->execute([
Expand Down
2 changes: 1 addition & 1 deletion frameworks/PHP/ubiquity/app/controllers/DbMy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DbMy extends Db_ {

public function update($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
$ids = $this->getUniqueRandomNumbers($count);
foreach ($ids as $id) {
$world = self::$pDao->execute([
Expand Down
5 changes: 2 additions & 3 deletions frameworks/PHP/ubiquity/app/controllers/DbRaw.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Bench controller.
*/
class DbRaw extends \Ubiquity\controllers\Controller {
use DbTrait;

protected static $statement;

Expand Down Expand Up @@ -44,7 +43,7 @@ public function index() {

public function query($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
while ($count --) {
self::$statement->execute([
\mt_rand(1, 10000)
Expand All @@ -57,7 +56,7 @@ public function query($queries = 1) {
public function update($queries = 1) {
$worlds = [];
$keys = $values = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);
for ($i = 0; $i < $count; ++ $i) {
$values[] = $keys[] = $id = \mt_rand(1, 10000);
self::$statement->execute([
Expand Down
6 changes: 3 additions & 3 deletions frameworks/PHP/ubiquity/app/controllers/Db_.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Bench controller.
*/
class Db_ extends \Ubiquity\controllers\Controller {
use DbTrait,DbAsyncTrait;
use DbAsyncTrait;

public function index() {
echo \json_encode(self::$pDao->execute([
Expand All @@ -19,7 +19,7 @@ public function index() {

public function query($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);

while ($count --) {
$worlds[] = (self::$pDao->execute([
Expand All @@ -31,7 +31,7 @@ public function query($queries = 1) {

public function update($queries = 1) {
$worlds = [];
$count = $this->getCount($queries);
$count = \min(\max((int) $queries, 1), 500);

while ($count --) {
$world = self::$pDao->execute([
Expand Down
15 changes: 0 additions & 15 deletions frameworks/PHP/ubiquity/app/controllers/utils/DbTrait.php

This file was deleted.

2 changes: 1 addition & 1 deletion frameworks/PHP/ubiquity/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require" : {
"php" : "^7.4",
"php" : ">=7.4",
"phpmv/ubiquity" : "dev-master"
},
"require-dev" : {
Expand Down
3 changes: 2 additions & 1 deletion frameworks/PHP/ubiquity/deploy/conf/ubiquity-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"user" => "benchmarkdbuser", // benchmarkdbuser
"password" => "benchmarkdbpass", // benchmarkdbpass
"options" => [
\PDO::ATTR_PERSISTENT => true
\PDO::ATTR_PERSISTENT => true,
\PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
],
"cache" => false
]
Expand Down
12 changes: 6 additions & 6 deletions frameworks/PHP/ubiquity/ubiquity.dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
FROM ubuntu:20.04
FROM ubuntu:20.10

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get update -yqq > /dev/null && \
apt-get install -yqq nginx git unzip php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql > /dev/null
apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql > /dev/null

RUN apt-get install -yqq composer > /dev/null

COPY deploy/conf/* /etc/php/7.4/fpm/
COPY deploy/conf/* /etc/php/8.0/fpm/

ADD ./ /ubiquity
WORKDIR /ubiquity

RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/7.4/fpm/php-fpm.conf ; fi;
RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.0/fpm/php-fpm.conf ; fi;

RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet

RUN chmod 777 -R /ubiquity/app/cache/*

COPY deploy/conf/ubiquity-config.php app/config/config.php

RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/fpm/php.ini
RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/8.0/fpm/php.ini

CMD service php7.4-fpm start && \
CMD service php8.0-fpm start && \
nginx -c /ubiquity/deploy/nginx.conf -g "daemon off;"