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

class-woothemes-sensei-certificate-templates.php returns empty array in PHP 8.x #328

Open
cena opened this issue Feb 2, 2023 · 1 comment

Comments

@cena
Copy link

cena commented Feb 2, 2023

reported in 5896322-zen

This issue arose when user was attempting to use the Colibri theme with Certificates, and getting a fatal error on previewing the template. Note that the user is using the Pro version; the link above is to free.

After enabling Query Monitor, the detailed error is:

SCR-20230126-b8r


Note: user was using PHP 8.0.26 when the issue was originally reported.

Testing:

I can duplicate this error by setting PHP to version 8.x (on Pressable, 7.4 seems to work), and with or without Colibi active, when creating and previewing a NEW certificate template.

The user contacted Colibri, who responded:

in the ../sensei-certificates/classes/class-woothemes-sensei-certificate-templates.php file, lines 444-449 don't reflect the correct defaults as shown on lines 283-290. This results in `$font['font_style']` returning an empty array on line 722 instead of an empty string. This will not cause an issue on PHP7, types don't cause fatal errors.

Solutions [for user]:
- ask the Sensei Certificates developer to fix the issue in an update, you can mention to them what we wrote above.
- downgrade to PHP7
- select a font style so that it doesn't return an empty array and the preview will work, please see -> https://bit.ly/3WTha2P

On an existing template, I attempted to set the fonts for each part of the template as Colibri indicated above, and still generated the error seen in the above screenshot.

In addition to setting the fonts, I had to EITHER:

  • set a default font style (bold/italic)
  • set a font style for each component

Also: if you set just the default font AND style, you don't have to set component fonts or styles.

So, a slightly caveat-ed confirmation that Colibri's solution works in 8.0, 8.1.

8.2 generates a 502 bad gateway error I can't seem to track down.


PHP 7.4, 8.0, 8.1, 8.2
WP: 6.1.1
Sensei Pro: 4.11.0.1.11.0
Certificates: 2.3.0

@cena cena added the [Type] Bug label Feb 2, 2023
@ExtremityExperts
Copy link

Thanks for the thorough bug write up Cena! You rock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants