Post by rufus.d » Sat Jan 27, 2024 4:11 pm

Hi Everyone,

I recently upgraded the OC version from 3.0.3.6 to 3.0.3.9. All went normal without any issues, and I also updated the Journal theme without any issues.

But, when I switch my PHP version from 8.0 to 8.1/8.2, then I get 3 errors every time of launching the front end store. Apart from that don't see any other major issues.

Things to notice:
-Storage folders under the system are placed outside the public_html path.
-Storage folders has the permission 755 as well.
-Issue not only related to Journal theme, but also on the main site.
-No errors on the Admin panel
-If the PHP version switched back to 8.0, the errors are gone, no issues.

PHP version: 8.2
OC version: 3.0.3.9
Journal Theme: 3.1.13


Error Logs:
2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 35

2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 40

2024-01-27 13:32:16 - PHP Unknown: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ux2501/domains/website.com/public_html/catalog/controller/journal3/seo.php on line 74

Any help or suggestions will be much appreciated.

Newbie

Posts

Joined
Sat Jan 27, 2024 4:02 pm

Post by IP_CAM » Sat Jan 27, 2024 5:53 pm

This seems to be a Journal Theme related Problem. So, better contact Journal Theme on this, Journal is not supported on this Forum.

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by rufus.d » Sat Jan 27, 2024 6:09 pm

The first two errors are more related to PHP deprecated functions. Some of the expressions are supported in PHP 8.0, while not supported in 8.1 and 8.2.

Need a solution for the following errors at least.

2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 35

2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 40

Newbie

Posts

Joined
Sat Jan 27, 2024 4:02 pm

Post by IP_CAM » Sat Jan 27, 2024 6:40 pm

As I wrote, you have to contact Journal Support on this, Journal equipped OC Versions are NOT supported in the FREE Forum Sections here.

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by rufus.d » Sat Jan 27, 2024 7:08 pm

Hi Everyone,
This info is applicable to all users who are trying to switch the PHP version from 8.0 to 8.1 and 8.2.

PHP has deprecated these functions: count(); jsonSerialize() and trim()

So, in short if any of your files has these functions, you may have to edit the php files using your control panel.

I have posted some of the examples below for reference, this may need to be modified based on the file you have them as reference.

Error for count()
2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 35

Go to the file Markup.php as mentioned in the above path and change the following function on line 35:

Code: Select all

   public function count()
    {
        return mb_strlen($this->content, $this->charset);
    }
Change AS:

Code: Select all

public function [b]count(): int[/b]
    {
        return mb_strlen($this->content, $this->charset);
    }
Error for jsonSerialize()
2024-01-27 13:32:16 - PHP Unknown: Return type of Twig\Markup::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/ux2501/domains/website.com/public_html/system/storageux2501/vendor/twig/twig/src/Markup.php on line 40

Go to the file Markup.php as mentioned in the above path and change the following function on line 40:

Code: Select all

  public function jsonSerialize()
    {
        return $this->content;
    }
Change AS:

Code: Select all

  public function [b]jsonSerialize(): mixed[/b]
    {
        return $this->content;
    }

Error for trim()
2024-01-27 9:27:28 - PHP Unknown: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ux2501/domains/website.com/public_html/catalog/controller/journal3/seo.php on line 74


Go to the respective seo.php file as mentioned in the above path and change the following function on line 74:

Code: Select all

			$tags['twitter:site'] = array(
				'type'    => 'name',
				'content' => '@' . trim($this->journal3->settings->get('seoTwitterCardsTwitterUser'), '@'),
			);
Change AS:

Code: Select all

			$tags['twitter:site'] = array(
				'type'    => 'name',
				'content' => '@' . trim($this->journal3->settings->get('seoTwitterCardsTwitterUser')[b] ?? [/b]'@'),
			);

Remember, these are PHP deprecated functions, it has nothing to do with the paid products like Journal, or other extensions. You may have to go through the errors in your website logs and modify them accordingly as mentioned above. For more reference, go to Stack Overflow.
Last edited by rufus.d on Sun Jan 28, 2024 5:55 pm, edited 1 time in total.

Newbie

Posts

Joined
Sat Jan 27, 2024 4:02 pm

Post by JNeuhoff » Sat Jan 27, 2024 9:02 pm

What's you website URL? And on what exact page do you get this error?

I don't get any of these errors on OC 3.0.3.9 using PHP 8.3. Hence it looks like the Journal3 framework uses some obscure twig functions causing your errors, which wouldn't surprise me given that the Journal3 framework isn't based on a proper MVC design. It has too much controller logic embedded in it's twig templates and javascripts where it doesn't belong!

Try it on a standard OC 3.0.3.9 to see whether it still results in the same errors or not.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Sat Jan 27, 2024 9:22 pm

The error is specifically to do with your theme

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by ADD Creative » Sat Jan 27, 2024 10:38 pm

Your Twig is old and not the version included in 3.0.3.9. You need to update your storage directory.

3.0.3.9 has the suppressor in.
https://github.com/opencart/opencart/bl ... hp#L38-L39

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 5 guests