Updating Old FAQ Addon

Open to all! Ask other shopowners for help.
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

ecartz wrote: Sat Feb 11, 2023 9:26 pm That error would go away if you changed the line to

Code: Select all

if (is_array($languages) && (count($languages) > 1)) {
But a better solution might be to change whatever is setting $languages to be a string. Because it may have other side effects.
@ecartz I know you're right and this hole is getting deeper as now these warnings have appeared in the admin error log and they are totally new to me.
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of database_core::query($sql, $resultmode = MYSQLI_STORE_RESULT) should either be compatible with mysqli::query(string $query, int $result_mode = MYSQLI_STORE_RESULT): mysqli_result|bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.1/database_core.php on line 61
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of Href::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.5/href.php on line 145
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::open($save_path, $session_name) should either be compatible with SessionHandler::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 27
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::close() should either be compatible with SessionHandler::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 15
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::read($key) should either be compatible with SessionHandler::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 31
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::write($key, $value) should either be compatible with SessionHandler::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 47
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::destroy($key) should either be compatible with SessionHandler::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 19
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::gc($maxlifetime) should either be compatible with SessionHandler::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 23
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::validateId($key) should either be compatible with SessionUpdateTimestampHandlerInterface::validateId(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 42
[12-Feb-2023 09:35:36 Europe/London] PHP Deprecated: Return type of mysql_session::updateTimestamp($key, $ignore) should either be compatible with SessionUpdateTimestampHandlerInterface::updateTimestamp(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/demo/public_html/includes/system/versioned/1.0.8.3/mysql_session.php on line 38


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Updating Old FAQ Addon

Post by ecartz »

Options:

1. Do what it says and add the #[\ReturnTypeWillChange] attribute.
2. Add return types to those methods to match what is expected.
3. Turn off deprecation notices in error reporting.
4. Use PHP 8.0 or earlier instead.

More discussion: https://stackoverflow.com/q/71133749/6660678

Examples:

Code: Select all

// set the level of error reporting
  error_reporting(E_ALL^E_DEPRECATED);

Code: Select all

    #[\ReturnTypeWillChange]
    public function query($sql, $resultmode = MYSQLI_STORE_RESULT) {

Code: Select all

    public function query($sql, $resultmode = MYSQLI_STORE_RESULT): mysqli_result|bool {
Note that for the last, the deprecated message tells you what it needs to be. This example is specific to the first message.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply