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

Added PHP 8.2 support #12071

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions upload/admin/controller/tool/store.php
Expand Up @@ -42,11 +42,12 @@ public function createStoreInstance(int $store_id = 0, string $language = '', st
$registry->set('load', $loader);

// Create a dummy request class so we can feed the data to the order editor
$request = new \stdClass();
$request = new \Opencart\System\Library\Request();
$request->get = [];
$request->post = [];
$request->server = $this->request->server;
$request->cookie = [];
$request->files = [];

// Request
$registry->set('request', $request);
Expand Down Expand Up @@ -123,4 +124,4 @@ public function createStoreInstance(int $store_id = 0, string $language = '', st

return $registry;
}
}
}
6 changes: 6 additions & 0 deletions upload/system/library/cart/cart.php
Expand Up @@ -2,6 +2,12 @@
namespace Opencart\System\Library\Cart;
class Cart {
private array $data = [];
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\Cart\Customer $customer;
private \Opencart\System\Library\Session $session;
private \Opencart\System\Library\DB $db;
private \Opencart\System\Library\Cart\Tax $tax;
private \Opencart\System\Library\Cart\Weight $weight;

/**
* Constructor
Expand Down
22 changes: 12 additions & 10 deletions upload/system/library/cart/currency.php
Expand Up @@ -2,6 +2,8 @@
namespace Opencart\System\Library\Cart;
class Currency {
private array $currencies = [];
private \Opencart\System\Library\DB $db;
private \Opencart\System\Library\Language $language;

/**
* Constructor
Expand Down Expand Up @@ -50,9 +52,9 @@ public function format(float $number, string $currency, float $value = 0, bool $
}

$amount = $value ? (float)$number * $value : (float)$number;

$amount = round($amount, $decimal_place);

if (!$format) {
return $amount;
}
Expand All @@ -71,7 +73,7 @@ public function format(float $number, string $currency, float $value = 0, bool $

return $string;
}

/**
* Convert
*
Expand All @@ -96,14 +98,14 @@ public function convert(float $value, string $from, string $to): float {

return $value * ($to / $from);
}

/**
* getId
*
* @param string $currency
*
* @return int
*/
*/
public function getId(string $currency): int {
if (isset($this->currencies[$currency])) {
return $this->currencies[$currency]['currency_id'];
Expand All @@ -118,15 +120,15 @@ public function getId(string $currency): int {
* @param string $currency
*
* @return string
*/
*/
public function getSymbolLeft(string $currency): string {
if (isset($this->currencies[$currency])) {
return $this->currencies[$currency]['symbol_left'];
} else {
return '';
}
}

/**
* getSymbolRight
*
Expand All @@ -141,7 +143,7 @@ public function getSymbolRight(string $currency): string {
return '';
}
}

/**
* getDecimalPlace
*
Expand All @@ -156,7 +158,7 @@ public function getDecimalPlace(string $currency): string {
return 0;
}
}

/**
* getValue
*
Expand All @@ -172,7 +174,7 @@ public function getValue(string $currency): float {
return 0;
}
}

/**
* Has
*
Expand Down
14 changes: 9 additions & 5 deletions upload/system/library/cart/customer.php
Expand Up @@ -8,6 +8,10 @@ class Customer {
private string $email = '';
private string $telephone = '';
private bool $newsletter = false;
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\DB $db;
private \Opencart\System\Library\Request $request;
private \Opencart\System\Library\Session $session;

/**
* Constructor
Expand Down Expand Up @@ -85,7 +89,7 @@ public function login(string $email, string $password, bool $override = false):
return false;
}
}

/**
* Logout
*
Expand Down Expand Up @@ -120,7 +124,7 @@ public function isLogged(): bool {
public function getId(): int {
return $this->customer_id;
}

/**
* getFirstName
*
Expand All @@ -138,7 +142,7 @@ public function getFirstName(): string {
public function getLastName(): string {
return $this->lastname;
}

/**
* getGroupId
*
Expand All @@ -147,7 +151,7 @@ public function getLastName(): string {
public function getGroupId(): int {
return $this->customer_group_id;
}

/**
* getEmail
*
Expand Down Expand Up @@ -189,7 +193,7 @@ public function getAddressId(): int {
return 0;
}
}

/**
* getBalance
*
Expand Down
2 changes: 2 additions & 0 deletions upload/system/library/cart/length.php
Expand Up @@ -2,6 +2,8 @@
namespace Opencart\System\Library\Cart;
class Length {
private array $lengths = [];
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\DB $db;

/**
* Constructor
Expand Down
4 changes: 3 additions & 1 deletion upload/system/library/cart/tax.php
Expand Up @@ -2,6 +2,8 @@
namespace Opencart\System\Library\Cart;
class Tax {
private array $tax_rates = [];
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\DB $db;

/**
* Constructor
Expand Down Expand Up @@ -182,7 +184,7 @@ public function getRates(float $value, int $tax_class_id): array {

return $tax_rate_data;
}

/**
* Clear
*
Expand Down
17 changes: 10 additions & 7 deletions upload/system/library/cart/user.php
Expand Up @@ -6,6 +6,9 @@ class User {
private int $user_group_id = 0;
private string $email = '';
private array $permission = [];
private \Opencart\System\Library\DB $db;
private \Opencart\System\Library\Request $request;
private \Opencart\System\Library\Session $session;

/**
* Constructor
Expand Down Expand Up @@ -42,7 +45,7 @@ public function __construct(\Opencart\System\Engine\Registry $registry) {
}
}
}

/**
* Login
*
Expand Down Expand Up @@ -91,7 +94,7 @@ public function login(string $username, string $password): bool {
return false;
}
}

/**
* Logout
*
Expand All @@ -105,7 +108,7 @@ public function logout(): void {
$this->user_group_id = 0;
$this->email = '';
}

/**
* hasPermission
*
Expand All @@ -121,7 +124,7 @@ public function hasPermission(string $key, mixed $value): bool {
return false;
}
}

/**
* isLogged
*
Expand All @@ -130,7 +133,7 @@ public function hasPermission(string $key, mixed $value): bool {
public function isLogged(): bool {
return $this->user_id ? true : false;
}

/**
* getId
*
Expand All @@ -148,7 +151,7 @@ public function getId(): int {
public function getUserName(): string {
return $this->username;
}

/**
* getGroupId
*
Expand All @@ -157,7 +160,7 @@ public function getUserName(): string {
public function getGroupId(): int {
return $this->user_group_id;
}

/**
* getEmail
*
Expand Down
4 changes: 3 additions & 1 deletion upload/system/library/cart/weight.php
Expand Up @@ -2,6 +2,8 @@
namespace Opencart\System\Library\Cart;
class Weight {
private array $weights = [];
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\DB $db;

/**
* Constructor
Expand Down Expand Up @@ -52,7 +54,7 @@ public function convert(float $value, string $from, string $to): float {

return $value * ($to / $from);
}

/**
* Format
*
Expand Down
6 changes: 3 additions & 3 deletions upload/system/library/db/mysqli.php
Expand Up @@ -20,8 +20,8 @@ public function __construct(string $hostname, string $username, string $password
try {
$mysqli = @new \MySQLi($hostname, $username, $password, $database, $port);

mysqli_report(MYSQLI_REPORT_ERROR);
$this->connection = $mysqli;
$this->connection->report_mode = MYSQLI_REPORT_ERROR;
$this->connection->set_charset('utf8mb4');
$this->connection->query("SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION'");
$this->connection->query("SET FOREIGN_KEY_CHECKS = 0");
Expand Down Expand Up @@ -76,7 +76,7 @@ public function query(string $sql): bool|object {
public function escape(string $value): string {
return $this->connection->real_escape_string($value);
}

/**
* countAffected
*
Expand All @@ -94,7 +94,7 @@ public function countAffected(): int {
public function getLastId(): int {
return $this->connection->insert_id;
}

/**
* isConnected
*
Expand Down
7 changes: 7 additions & 0 deletions upload/system/library/mail.php
Expand Up @@ -21,6 +21,13 @@ class Mail {
protected string $text = '';
protected string $html = '';
protected array $attachments = [];
public string $smtp_hostname = '';
public string $smtp_username = '';
public string $smtp_password = '';
public int $smtp_port = 25;
public int $smtp_timeout = 5;
protected int $max_attempts = 3;
public string $parameter;

/**
* Constructor
Expand Down
4 changes: 3 additions & 1 deletion upload/system/library/mail/smtp.php
Expand Up @@ -217,7 +217,9 @@ public function send(): bool {
$lines = explode("\n", $message);

foreach ($lines as $line) {
$results = str_split($line, 998);
// $results = str_split($line, 998);
// see https://php.watch/versions/8.2/str_split-empty-string-empty-array
$results = ($line === '') ? [''] : str_split($line, 998);

foreach ($results as $result) {
fputs($handle, $result . "\r\n");
Expand Down
11 changes: 6 additions & 5 deletions upload/system/library/request.php
Expand Up @@ -14,10 +14,11 @@
class Request {
public array $get = [];
public array $post = [];
protected array $request = [];
public array $cookie = [];
public array $files = [];
public array $server = [];

/**
* Constructor
*/
Expand All @@ -29,13 +30,13 @@ public function __construct() {
$this->files = $this->clean($_FILES);
$this->server = $this->clean($_SERVER);
}

/**
*
*
* @param array $data
*
* @return array
*/
* @return array
*/
public function clean(mixed $data): mixed {
if (is_array($data)) {
foreach ($data as $key => $value) {
Expand Down