https://github.com/CE-PhoenixCart/PhoenixCart/issues/36
Adding support for PHP 8.1?
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Adding support for PHP 8.1?
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Adding support for PHP 8.2?
This is not within the scope of php8.x problems.cdgo wrote: ↑Sun Apr 09, 2023 8:23 am One of the issues which ofcourse is not directly caused by the core, but I think should be handled by the core is the failling of translations:
PHP Fatal error: Uncaught Error: Undefined constant "TITLE" in /home/user/domains/domain/public_html/includes/classes/application.php:65
The adding of all the nessecary translations is part of the added plugin, but there should be a fallback to prevent the whole shop to seize working when only a translations is missing.
Most likely it happens in the additional languages so a fallback to the default language should be working for those cases.
And if it is in the default language, a default output could be used like "mising translation" or even just one space.
In any case, it's not the job of the core to try to fix plugin "error" - if core starts doing that, where does it end?
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
Re: Adding support for PHP 8.2?
In PHP 8.1 it's a "PHP Fatal error" so breaking the whole webshop.burt wrote: ↑Sun Apr 09, 2023 9:22 amThis is not within the scope of php8.x problems.cdgo wrote: ↑Sun Apr 09, 2023 8:23 am One of the issues which ofcourse is not directly caused by the core, but I think should be handled by the core is the failling of translations:
PHP Fatal error: Uncaught Error: Undefined constant "TITLE" in /home/user/domains/domain/public_html/includes/classes/application.php:65
The adding of all the nessecary translations is part of the added plugin, but there should be a fallback to prevent the whole shop to seize working when only a translations is missing.
Most likely it happens in the additional languages so a fallback to the default language should be working for those cases.
And if it is in the default language, a default output could be used like "mising translation" or even just one space.
In any case, it's not the job of the core to try to fix plugin "error" - if core starts doing that, where does it end?
Strictly spoken, an addon or plugin is not the concern of the core.
And a translation pack for the core's language pack is also an add on.
But this is a very common made mistake, so there for I thought it would be a nice fallback of the core to prevent these type of errors.
- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Adding support for PHP 8.1?
So with the above, what is the solution on strftime()?
example includes/modules/notifications/templates/tpl_n_checkout.php
The strftime is used in various other addon modules
Then admin/includes/classes/object_info.php
This part is giving Deprecated errors - Deprecated: Creation of dynamic property objectInfo::
example includes/modules/notifications/templates/tpl_n_checkout.php
The strftime is used in various other addon modules
Then admin/includes/classes/object_info.php
Code: Select all
public function objectInfo($object_data) {
foreach($object_data as $key => $value) {
$this->$key = is_null($value) ? null
: filter_var($value, FILTER_CALLBACK, ['options' => 'Text::prepare']);
}
}
-
cut-n-paste
- Member
- Posts: 28
- Joined: Fri Oct 07, 2022 12:20 pm
- Phoenix Version:
- Has thanked: 2 times
- Been thanked: 5 times
Re: Adding support for PHP 8.1?
This is what I have found so far:
/includes/system/versioned/1.0.8.3/date.php needs deprecated strftime() replaced. EDIT: added internationalisation with IntlDateFormatter
The following files need all public functions prepended with as suggested in the error message:
includes/system/versioned/1.0.8.1/database_core.php
includes/system/versioned/1.0.8.3/mysql_session.php
includes/system/versioned/1.0.8.5/href.php
EDIT: I did this in includes/system/override, but have since then I have found there are also other files including files in admin area that need strftime() replaced. There is no override for admin area according to @burt and so the core files need to be edited as far as I can tell.
Good information on the return type issue and the way to fix this for PHP 9+ in this question on stack overflow https://stackoverflow.com/questions/711 ... -or-the-re
To be done - replace strftime() in the following files:
admin/define_language.php
admin/includes/classes/logger.php
includes/application_bottom.php
includes/modules/content/index/templates/tpl_cm_i_card_products.php
includes/modules/content/index_nested/templates/tpl_cm_in_card_products.php
includes/modules/notifications/templates/tpl_n_checkout.php
/includes/system/versioned/1.0.8.3/date.php needs deprecated strftime() replaced. EDIT: added internationalisation with IntlDateFormatter
Code: Select all
public function format($format) {
if ($this->timestamp) {
$dateFormat = Date::strftimeToDateFormat($format);
$locale = locale_get_default();
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::MEDIUM);
$timestamp = $this->timestamp;
return $formatter->format($timestamp);
} else {
return false;
}
}
public static function strftimeToDateFormat($strftimeFormat) {
$conversion = array(
'%a' => 'D', // Abbreviated weekday name
'%A' => 'l', // Full weekday name
'%b' => 'M', // Abbreviated month name
'%B' => 'F', // Full month name
'%c' => 'r', // Date and time representation
'%C' => 'y', // Century (00-99)
'%d' => 'd', // Day of the month (01-31)
'%D' => 'm/d/y', // Short date (mm/dd/yy)
'%e' => 'j', // Day of the month (1-31)
'%F' => 'Y-m-d', // ISO 8601 date (YYYY-MM-DD)
'%g' => 'y', // Last 2 digits of the week-based year (00-99)
'%G' => 'Y', // Week-based year
'%h' => 'M', // Abbreviated month name (same as %b)
'%H' => 'H', // Hour in 24-hour format (00-23)
'%I' => 'h', // Hour in 12-hour format (01-12)
'%j' => 'z', // Day of the year (001-366)
'%m' => 'm', // Month (01-12)
'%M' => 'i', // Minute (00-59)
'%p' => 'A', // AM or PM
'%r' => 'h:i:s A', // 12-hour time (hh:mm:ss AM/PM)
'%R' => 'H:i', // 24-hour time (hh:mm)
'%S' => 's', // Second (00-59)
'%T' => 'H:i:s', // 24-hour time with seconds (hh:mm:ss)
'%u' => 'N', // Day of the week (1-7, 1=Monday, 7=Sunday)
'%U' => 'W', // Week number of the year (00-53, Sunday as the first day of the week)
'%V' => 'W', // ISO week number of the year (01-53)
'%w' => 'w', // Day of the week (0-6, 0=Sunday, 6=Saturday)
'%x' => 'Y-m-d', // Locale's date representation
'%X' => 'H:i:s', // Locale's time representation
'%y' => 'y', // Last 2 digits of the year (00-99)
'%Y' => 'Y', // Year with century (e.g., 2023)
'%z' => 'O', // Timezone offset (+HHMM or -HHMM)
'%Z' => 'T', // Timezone name
'%%' => '%', // A literal '%'
);
$dateFormat = strtr($strftimeFormat, $conversion);
return $dateFormat;
}
The following files need all public functions prepended with
Code: Select all
#[\ReturnTypeWillChange]includes/system/versioned/1.0.8.1/database_core.php
includes/system/versioned/1.0.8.3/mysql_session.php
includes/system/versioned/1.0.8.5/href.php
EDIT: I did this in includes/system/override, but have since then I have found there are also other files including files in admin area that need strftime() replaced. There is no override for admin area according to @burt and so the core files need to be edited as far as I can tell.
Good information on the return type issue and the way to fix this for PHP 9+ in this question on stack overflow https://stackoverflow.com/questions/711 ... -or-the-re
To be done - replace strftime() in the following files:
admin/define_language.php
admin/includes/classes/logger.php
includes/application_bottom.php
includes/modules/content/index/templates/tpl_cm_i_card_products.php
includes/modules/content/index_nested/templates/tpl_cm_in_card_products.php
includes/modules/notifications/templates/tpl_n_checkout.php
Last edited by cut-n-paste on Mon Nov 13, 2023 1:51 pm, edited 4 times in total.
- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Adding support for PHP 8.1?
@cut-n-paste
How to with strftime in example in admin/includes/classes/logger.php?
How to with strftime in example in admin/includes/classes/logger.php?
Code: Select all
error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);-
cut-n-paste
- Member
- Posts: 28
- Joined: Fri Oct 07, 2022 12:20 pm
- Phoenix Version:
- Has thanked: 2 times
- Been thanked: 5 times
Re: Adding support for PHP 8.1?
@Pierre_P Read my edited post, then I think you can just replace with
Code: Select all
strftime(STORE_PARSE_DATE_TIME_FORMAT)Code: Select all
date(Date::strftimeToDateFormat(STORE_PARSE_DATE_TIME_FORMAT))- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Adding support for PHP 8.2?
@burtburt wrote: ↑Sun Apr 09, 2023 9:22 amThis is not within the scope of php8.x problems.cdgo wrote: ↑Sun Apr 09, 2023 8:23 am One of the issues which ofcourse is not directly caused by the core, but I think should be handled by the core is the failling of translations:
PHP Fatal error: Uncaught Error: Undefined constant "TITLE" in /home/user/domains/domain/public_html/includes/classes/application.php:65
The adding of all the nessecary translations is part of the added plugin, but there should be a fallback to prevent the whole shop to seize working when only a translations is missing.
Most likely it happens in the additional languages so a fallback to the default language should be working for those cases.
And if it is in the default language, a default output could be used like "mising translation" or even just one space.
In any case, it's not the job of the core to try to fix plugin "error" - if core starts doing that, where does it end?
Absolutely weird today!
I am sitting with same issue.
Without any reference to constant TITLE i have added a new page called extract.php.
Behold - Error: Undefined constant "TITLE" in C:\xampp\htdocs\phoenix82\includes\classes\application.php on line 65
Even if i specify the constant TITLE the errors just keeps coming from there.
What i have done:
Added new file extract.php in root folder with the necessary require 'includes/application_top.php'; and so on - similar to existing files.
I did then add language file extract.php to english - there's no constants in there yet as i do not have any.
Added file in templates (templates/overide/includes/pages/extract.php
What am i doing wrong?
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Adding support for PHP 8.2?
1. make new pages in the base template: default
As the override template *extends* the default template.
2. make sure language files have necessary const's in them
otherwise you will get errors.
Therefore a new page for your site should consist of a minimum of three files, maybe more depending on extra languages and so on;
/extract.php
/includes/languages/english/extract.php
/templates/default/includes/pages/extract.php
What is this "extract.php" for ?
What does it do, how is it used?
- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Adding support for PHP 8.2?
I did move file to templates/default/includes/pages/extract.php - same result
Busy creating a JSON request to get data from products to update windows SQL server for internal accounting program and then to automate this.