Vanilla 1.5.8a installation running on PHP 8.1.13 logging the following:
PHP Warning: Undefined variable $meta_products_price in /Users/zcdev/Sites/localhost/158atest/includes/modules/meta_tags.php on line 290.
Printable View
Vanilla 1.5.8a installation running on PHP 8.1.13 logging the following:
PHP Warning: Undefined variable $meta_products_price in /Users/zcdev/Sites/localhost/158atest/includes/modules/meta_tags.php on line 290.
Are you sure includes/modules/YOURTEMPLATE/meta_tags.php is based on includes/modules/meta_tags.php ?
I can't see a code path that yields this error.
i have my dev box running v158 with the responsive classic template; using php 8.1.12.
i am not able to reproduce this error. nor do i see what url the OP used to recreate this error. i tested any number of pages, including product pages where in theory this code would get executed.
in looking at the code, i agree that i do not understand how this var could potentially be undefined.
i also do not understand how a ZC developer since 2009 could not figure this one out on their own.
perhaps i am missing something?
Perhaps you would prefer that I fix any potential bugs in core code or modules myself and never bother to advise the dev team or original module author? That completely goes against the ethos of open source coding.
Reporting something doesn't imply that I can't "figure it out", and indeed, the variable shouldn't get to a situation where it is undefined, but clearly it is as it's there in the logs. I'll look into it further and when I find the cause I'll deal with it.
given that 3 contributors to his project have weighed in on this issue, i would hope that once you find the cause, you would share your findings here.
i can only speak for myself, and i know i am interested... and it would seem to be the ethical thing to do.
best.
It IS possible for $meta_products_price to be undefined.
When testing the scenario, only point 1 and point 2 get logged which means that in this test instanceCode:if (META_TAG_INCLUDE_PRICE == '1' and !strstr($_GET['main_page'], 'document_general')) {
error_log("point 1");
if ($product_info_metatags->fields['product_is_free'] != '1') {
error_log("point 2");
if (zen_check_show_prices() == true) {
error_log("point 3");
$meta_products_price = zen_get_products_actual_price($product_info_metatags->fields['products_id']);
$prod_is_call_and_no_price = ($product_info_metatags->fields['product_is_call'] == '1' && $meta_products_price == 0);
$meta_products_price = (!$prod_is_call_and_no_price ? SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : '');
}
} else {
error_log("point 4");
$meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
}
} else {
error_log("point 5");
$meta_products_price = '';
}
is obviously not true.Code:if (zen_check_show_prices() == true) {
In those circumstances, nothing defines $meta_products_price
$meta_products_price also needs to be defined ifis false.Code:zen_check_show_prices()
On the test site, users are required to login to see pricing.
The simple fix required is to add an else to thecheck so that you end up withCode:if (zen_check_show_prices() == true) {
Code:if (META_TAG_INCLUDE_PRICE == '1' and !strstr($_GET['main_page'], 'document_general')) {
if ($product_info_metatags->fields['product_is_free'] != '1') {
if (zen_check_show_prices() == true) {
$meta_products_price = zen_get_products_actual_price($product_info_metatags->fields['products_id']);
$prod_is_call_and_no_price = ($product_info_metatags->fields['product_is_call'] == '1' && $meta_products_price == 0);
$meta_products_price = (!$prod_is_call_and_no_price ? SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : '');
} else {
$meta_products_price = '';
}
} else {
$meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
}
} else {
$meta_products_price = '';
}
Er, the bit that you missed in the first code block you posted is highlighted below (that's line 264 that I referenced above):
Code:
} else {
$meta_products_price = '';
// build un-customized meta tag
if (META_TAG_INCLUDE_PRICE == '1' and !strstr($_GET['main_page'], 'document_general')) {
if ($product_info_metatags->fields['product_is_free'] != '1') {
if (zen_check_show_prices() == true) {
$meta_products_price = zen_get_products_actual_price($product_info_metatags->fields['products_id']);
$prod_is_call_and_no_price = ($product_info_metatags->fields['product_is_call'] == '1' && $meta_products_price == 0);
$meta_products_price = (!$prod_is_call_and_no_price ? SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : '');
}
} else {
$meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
}
}
if (META_TAG_INCLUDE_MODEL == '1' && !empty($product_info_metatags->fields['products_model'])) {
$meta_products_name = $product_info_metatags->fields['products_name'] . ' [' . $product_info_metatags->fields['products_model'] . ']';
} else {
$meta_products_name = $product_info_metatags->fields['products_name'];
}
$meta_products_name = zen_clean_html($meta_products_name);
$meta_products_description = zen_truncate_paragraph(strip_tags(stripslashes($product_info_metatags->fields['products_description'])), MAX_META_TAG_DESCRIPTION_LENGTH);
$meta_products_description = zen_clean_html($meta_products_description);
define('META_TAG_TITLE', str_replace('"','',$review_on . $meta_products_name . $meta_products_price . PRIMARY_SECTION . TITLE . TAGLINE));
define('META_TAG_DESCRIPTION', str_replace('"','',TITLE . ' ' . $meta_products_name . SECONDARY_SECTION . $meta_products_description . ' '));
define('META_TAG_KEYWORDS', str_replace('"','',$meta_products_name . METATAGS_DIVIDER . KEYWORDS));
} // CUSTOM META TAGS
when i look at the code, just above the code that you have there, i see:
do you not have that in your code?PHP Code:
$meta_products_price = '';
see:
https://github.com/zencart/zencart/b....php#L264-L270
perhaps that line is not in the v158a fileset that you are using?
see this merged PR:
https://github.com/zencart/zencart/p...c06b299b40b7d2
it seems it was corrected almost 2 months ago.
best.
Hmm, I'll check the 1.5.8a download I have
My head is spinning reviewing this.
Was this change made subsequent to the release of 1.5.8a?
BTW, this:
> On the test site, users are required to login to see pricing.
Is a pretty important detail.
> If it was fixed 2 months ago I would have expected the downloadable package to have been updated.
That's not how it works.
The downloadable package is updated when a release is done. Releases are only done when a critical mass of bug fixes warrants it. And a new release would not re-use the name 1.5.8a - it would be called 1.5.8b or something else.
You can check the deltas between Github and the last release any time to see what has been fixed since the last release.
the 158a fileset does not have the fix, see:
https://github.com/zencart/zencart/b.../meta_tags.php
with regards to the download, as swguy guy stated, it is not how it works.
if it was me, and i was a developer supporting ZC, i would learn the process and check to see if bugs have already been fixed on the github repo prior to posting here on the forum. and when i am testing, i always use the latest code up on the repo as opposed to the lettered releases...
but hey that's just me...
best.
Hi Scott,
I'm aware of the naming convention for updates to Zen Cart.
Whilst I can understand why you don't update the downloadable each time a bug fix is committed, it doesn't help those that are casual or first time users of Zen Cart. They can't be expected to go digging around in GitHub repos to see if any bugs have been reported and fixed.
I guess this is one the reasons why WooCommerce is such a popular eCommerce platform because bug fixes are rolled out automatically without the need for poking around GitHub to see what needs to be updated in freshly downloaded software.
Zen Cart really needs to become more user friendly to "non developers" if it wants to try and increase its market share.
> WooCommerce is such a popular eCommerce platform because bug fixes are rolled out automatically ...
Again, this is not how it works.
WooCommerce does do more frequent releases than Zen Cart does. Much more frequent.
But they don't release automatically; every release involves human decision making.
We could do more frequent releases too, but some storeowners complain if the release cadence is too frequent.
The approach we've taken is to release when a critical mass of bug fixes warrants it. It's a balance.
The team has worked hard over the past few releases to simplify, automate and document the release process, so that moving forward, more frequent releases could be a possibility. But we certainly wouldn't do a release just because there was a debug log created in an infrequently used configuration one one specific page.
Well, unfortunately that is the nature of the beast. There cannot be a release for every minor change.Quote:
They can't be expected to go digging around in GitHub repos to see if any bugs have been reported and fixed
ZC is a DIY solution, so yes it is beneficial to take an interest in what is going on in the development branch, precisely to catch these incremental fixes.
Everyone should subscribe to the notifications from the repository, if only to take an active interest in the development.
It is easy to use a Github client (I use Gitkraken, Windows) to see exactly what has been being added and why.
I incorporate all the changes pretty soon after they are merged, after testing of course...ideally users could be more active and do testing before they are merged.
Seeing the incremental changes helps to learn how things work.
It also becomes a constant "upgrade" process but it's one I do when convenient: it is not forced on me in a panic when hosting changes php with no warning and the debug logs pile up.
Zen Cart (nor any software of the ilk) cannot be fit and forget, since php versions and browser behaviours are moving targets, becoming ever stricter and continually forcing code tightening.