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

html_output.php causing search problems #6364

Open
mikeel100 opened this issue Mar 28, 2024 · 1 comment
Open

html_output.php causing search problems #6364

mikeel100 opened this issue Mar 28, 2024 · 1 comment

Comments

@mikeel100
Copy link

mikeel100 commented Mar 28, 2024

Zen Cart version: 1.5.8a
PHP version: 8.0.23
MySQL version: 10.4.25-MariaDB
Plugins that may be related: None...it happens in a clean install as well as my own plugin
What older/newer versions were also tested? Just 1.5.8a

In trying fix an issue with the search engine where prices from and price to do not go into the text boxes all the time, I've hit a snag that I can't explain and don't understand. I'm actively involved with Search Bug Reports on the Zen Cart Forum and this has been posted there as well.

My understanding of the process is that it starts in tpl_search_default.php and uses the $sData values from modules/pages/search/header_php.php...like so.

$sData['pto'] = (isset($_GET['pto']) ? zen_output_string($_GET['pto']) : '');

For troubleshooting purposes, I changed the above code to the code below...using 1000, '1000', and "1000" at many different points in my testing.

$sData['pto'] = 1000;

In tpl_search_default.php, line 37, I tested if $sData['pto'] was available and correct...like so.

<?php print_r('$sData[pto] before sanitizing = ' . $sData['pto'] . '<br>'); //this is not making it's way into zen_draw_input_field('pto', $sData['pto'], 'id="pto"'); below 

?>

It is available and correct but it is not getting into the text box.

So I moved on to verifying function zen_draw_input_field in the html_output.php file.

Around line 585, I tested for $value ($sData['pto']).

print_r('VALUE = ' . $value);
$field = '<input type="' . zen_output_string($type) . '" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
if (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && $reinsert_value == true) {
  $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
} elseif (zen_not_null($value)) {
  $field .= ' value="' . zen_output_string($value) . '"';
}
print_r('FIELD = ' . $field . ' | VALUE = ' . $value);

$value is still correct and available but it still isn't inside of the text box...but it should be, right? The empty text box appears at is should...other than being empty.

My confusion comes here while anylizing the above code. Why would you use $name in any part of this if statement below? The goal is to set $field .= ' value=" to the $value...not the $name, right?

if (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && $reinsert_value == true) {
  $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
}

So, I changed $name to $value and the text box now has the correct value in it.

Now, I'm reluctant to leave it this way because this function is WIDELY used throughout the programming.

My question, is this a good fix and a BUG?

I have no idea where the search engine NOTIFY system is located nor do I understand how the "watcher class" system works...so I couldn't analyze it.

I would appreciate some insight and help please.

@scottcwilson
Copy link
Sponsor Contributor

... nor do I understand how the "watcher class" system works

https://docs.zen-cart.com/dev/code/notifiers/

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

No branches or pull requests

2 participants