Template Pitech - Warning: Undefined Variable $moduleclass_sfx - Question | JoomShaper

Template Pitech - Warning: Undefined Variable $moduleclass_sfx

Renzo

Renzo

Template 1 day ago

In Pitech, everything works fine. However, if I set the Joomla error reporting to System Default, an undefined variable error appears on the Blog page.

See the following: Warning: Undefined variable $moduleclass_sfx in X:\wamp64\www\rpccare\templates\pitech\html\mod_articles_latest\default.php on line 13 Call Stack Time Memory Function Location 1 0.0001455968 {main}( ) ...\index.php:0 2 0.0001457528 require_once( 'X:\wamp64\www\rpccare\includes\app.php' ) ...\index.php:51 3 0.0018810688 Joomla\CMS\Application\CMSApplication->execute( ) ...\app.php:58 4 0.05101967936 Joomla\CMS\Application\SiteApplication->doExecute( ) ...\CMSApplication.php:320 5 0.05712333376 Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ) ...\SiteApplication.php:271 ... continues.

In PHP 8.3.14 and later, variables should be properly defined. During development I need to keep error reporting enabled. What can you tell me about this? Thank you and kind regards, Renzo

0
6 Answers
Ziaul Kabir
Ziaul Kabir
Accepted Answer
Support Agent 18 hours ago #219532

Hello Renzo,

Thank you for the detailed explanation.

You are correct that in PHP 8.x the error reporting has become stricter, and warnings such as “Undefined variable” are more visible when display_errors is enabled. In this case, the warning appears because the variable $moduleclass_sfx is not defined before being used in the template override file.

This does not affect the functionality of the site and is only a warning message, which is why you do not see it on the live server where display_errors is disabled.

However, for development environments where error reporting is enabled, it is indeed better practice to ensure that variables are properly defined before use. We will review this part of the template code and improve it in future updates to ensure better compatibility with newer PHP versions.

In the meantime, you can safely ignore this warning, or temporarily define the variable before it is used in the file if you prefer to keep a clean error log during development.

Thank you for bringing this to our attention.

Best regards.

0
Ziaul Kabir
Ziaul Kabir
Accepted Answer
Support Agent 1 day ago #219453

Hello,

Thanks for reaching out to us. Could you please share temporary administrator access to your Joomla backend? You can provide the credentials securely in the hidden content section. Also, please take a full backup of your site before we make any changes.

Once I have access, I’ll investigate further and see what’s causing the issue. Let me know once you’ve shared the details!

Best regards,

0
Renzo
Renzo
Accepted Answer
1 day ago #219488

Hi Ziaul, thanks for your interest. I’ll give you an update:

Once I put the site online, I didn’t encounter any errors. Analyzing the situation, I discovered that in php.ini the display_errors parameter is always set to Off. Locally (Wamp64), however, my display_errors parameter is On.

I need this to understand whether my programming, even though very minimal and simple, is written correctly.

Considering that in Joomla 6.x PHP version 8.x is used, I am using 8.3.30, and as we know, it is much more… how to put it… strict regarding errors and variable declarations. While previously it wasn’t always necessary to declare variables, now it’s almost required.

It seems that template updates, and even updates of other extensions not developed by you, did not always take this into account.

Reading the PHP 8 documentation, it seems to me that even if variables are not declared, they are still managed and the program flow is not affected. You will only get errors—or better, warning messages.

Serious errors, however, still remain.

What can you kindly tell me about this?

If you want to see the site, I’ll send you the parameters in the next message. Right now, I have a technical urgency.

Thank you for listening, and I hope I have been clear in my explanation.

Best regards, Renzo

0
Renzo
Renzo
Accepted Answer
16 hours ago #219543

Hello Ziaul,

Thank you for the precise reply, and of course I understand everything. As a C programmer, I understand that it is always difficult to keep up with evolution, especially when you have many products like you do.

In the meantime, I will take care of declaring the variables myself.

I wish you good work and send my kind regards. Renzo

0
Ziaul Kabir
Ziaul Kabir
Accepted Answer
Support Agent 14 hours ago #219557

You are welcome.

0
Renzo
Renzo
Accepted Answer
11 hours ago #219582

Hi, since I made it, the file in question is template/html/mod_articles_latest/default.php. I can also share it if you like, but I don’t know how. Is it safe to include code in the text even if it’s in a hidden section? Thanks and best regards, Renzo

0