PDA

View Full Version : Weird bug with browse form version 4.7.1, please fix



Wei Hong
May 1, 2019, 07:24 AM
Dear Flynax community,

I just found this weird bug and yes it effects me and I think many other who use browse form builder. Basically if you input any field into Browse Form Builder of the category, you will get one exact value for all listing show on listing list, even though we have different value from different listings. Here is how to reproduce it on flynax demo site

First go to admincp Browse Form Builder of Category Home here:
https://classifieds.demoflynax.com/admin/index.php?controller=categories&action=build&key=houses&form=short_form
- Try to remove Property for, Add City

Then check here:
https://classifieds.demoflynax.com/united-states/properties/houses.html
You will see all listing short/browse value as: Peoria
3217

Try again, but instead of City, try "State/Province/Region"
You will get all all listing short/browse value as: Arizona
3219

Try again with Garage
All No, when some of them are yes,
3218

Please fix this.

Rudi
May 1, 2019, 08:25 AM
Hello Wei,

We know about this bug and solution will be included in the next update

meanwhile, do the following to fix this problem:

go to ftp > includes > classes > rlListings.class.php > public function getListings > find /* replace hook */ (~728 row)

replace code below:


$sql = str_replace('{hook}', $hook, $sql);

...

...

return $listings;


with:


$sql = str_replace('{hook}', $hook, $sql);

$listings = $this->getAll($sql);
$listings = $GLOBALS['rlLang']->replaceLangKeys($listings, 'categories', 'name');

if (empty($listings)) {
return false;
}

$this->calc = $dbcount ?: $this->getRow("SELECT FOUND_ROWS() AS `calc`", 'calc');

$type = $rlListingTypes->types[$listing_type];

if ($type['Cat_general_only']) {
$shortFormFields = $this->getFormFields($type['Cat_general_cat'], 'short_forms', $listing_type);
$this->getFormFields($type['Cat_general_cat'], 'listing_titles', $listing_type);
}

foreach ($listings as &$listing) {
$rlCommon->listings[$listing['ID']] = $listing;

if (!$shortFormFields) {
$shortFormFields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}

$listingFields = $shortFormFields;

foreach ($listingFields as &$field) {
$field['value'] = $rlCommon->adaptValue(
$field,
$listing[$field['Key']],
'listing',
$listing['ID'],
true,
false,
false,
false,
$listing['Account_ID'],
null,
$listing['Listing_type']
);
}

$listing['fields'] = $listingFields;
$listing['listing_title'] = $this->getListingTitle(
$listing['Category_ID'],
$listing,
$listing['Listing_type'],
false,
$listing['Parent_IDs']
);
$listing['url'] = $this->getListingUrl($listing);

unset($field, $listingFields);
}

return $listings;



We apologize for any inconvenience!

Wei Hong
May 1, 2019, 12:14 PM
Hi Rudi,

I did the change but it didnt fix the problem, still the same California in all listing on my website. I think it was a problem in ftp > includes > classes > rlListing.class.php because I did experiment by copy old rlListing.class.php from version 4.6.2 to 4.7.1 and it shows correctly, I might be wrong. Anyway, I restore everything back to the way it was with the issue, and I created a ticket with my ftp info XJG-852954. Please take a look if you have the time. Thank you.

Wei Hong
May 1, 2019, 03:00 PM
Sorry, my bad!

I made a typo in class name

now it's correct

Hi Rudi,

I actually did replace your code in rlListing.class.php too earlier. But it has 2 problems:
1. The title of the listing in listing list return generic "listing"
2. If short form has category field, it will not show category. I have room for rent and I have it show category (room for rent) in short form and after replace code, the category no show in short form in listing list.

Other than these two issue, fields show correct as I get correct state and city now. May be another typo in your code?

Rudi
May 1, 2019, 04:10 PM
There is no typo anymore

I think you should create a ticket to look into it

or one last try:
use my quick solution to this, if it doesn't help it means there is something wrong with the settings on your site

revert all changes and below /* replace hook */

find and replace:


if (!$short_form_fields) {
$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}


with:


$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);




Better to use fix below, I've tested it again and it works

Wei Hong
May 1, 2019, 05:24 PM
There is no typo anymore

I think you should create a ticket to look into it

or one last try:
use my quick solution to this, if it doesn't help it means there is something wrong with the settings on your site

revert all changes and below /* replace hook */

find and replace:


if (!$short_form_fields) {
$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}


with:


$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);


Hi Rudi,

I just revert everything to where it has problem and apply this simple change, just remove IF. And it worked. So no need for the change above
Thank you for your help :)))

Pete Young
May 5, 2019, 01:05 PM
Hello Wei, Can I get some clarification on this fix please ? you say you just removed the > if ? does that include the bottom close bracket ? example


if (!$short_form_fields) {
$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}

to


(!$short_form_fields) {
$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
}


or do I have it wrong ?

Pete

Wei Hong
May 5, 2019, 02:20 PM
Hi Pete,

Just delete the red part


if (!$short_form_fields) {
$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}

It should be like this


$short_form_fields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);

Pete Young
May 5, 2019, 02:36 PM
Ok Brilliant I have it, thanks

Rudi
May 6, 2019, 03:55 AM
Guys,

You'd better use the final solution I mentioned below, it works properly

so I've posted here again:


go to ftp > includes > classes > rlListings.class.php > public function getListings > find /* replace hook */ (~728 row)

replace code below:


$sql = str_replace('{hook}', $hook, $sql);

...

...

return $listings;


with:


$sql = str_replace('{hook}', $hook, $sql);

$listings = $this->getAll($sql);
$listings = $GLOBALS['rlLang']->replaceLangKeys($listings, 'categories', 'name');

if (empty($listings)) {
return false;
}

$this->calc = $dbcount ?: $this->getRow("SELECT FOUND_ROWS() AS `calc`", 'calc');

$type = $rlListingTypes->types[$listing_type];

if ($type['Cat_general_only']) {
$shortFormFields = $this->getFormFields($type['Cat_general_cat'], 'short_forms', $listing_type);
$this->getFormFields($type['Cat_general_cat'], 'listing_titles', $listing_type);
}

foreach ($listings as &$listing) {
$rlCommon->listings[$listing['ID']] = $listing;

if (!$shortFormFields) {
$shortFormFields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}

$listingFields = $shortFormFields;

foreach ($listingFields as &$field) {
$field['value'] = $rlCommon->adaptValue(
$field,
$listing[$field['Key']],
'listing',
$listing['ID'],
true,
false,
false,
false,
$listing['Account_ID'],
null,
$listing['Listing_type']
);
}

$listing['fields'] = $listingFields;
$listing['listing_title'] = $this->getListingTitle(
$listing['Category_ID'],
$listing,
$listing['Listing_type'],
false,
$listing['Parent_IDs']
);
$listing['url'] = $this->getListingUrl($listing);

unset($field, $listingFields);
}

return $listings;

Pete Young
May 6, 2019, 03:56 AM
Thanks Rudi, appreciated.

Wei Hong
May 6, 2019, 04:04 AM
Guys,

You'd better use the final solution I mentioned below, it works properly

so I've posted here again:


go to ftp > includes > classes > rlListings.class.php > public function getListings > find /* replace hook */ (~728 row)

replace code below:


$sql = str_replace('{hook}', $hook, $sql);

...

...

return $listings;


with:


$sql = str_replace('{hook}', $hook, $sql);

$listings = $this->getAll($sql);
$listings = $GLOBALS['rlLang']->replaceLangKeys($listings, 'categories', 'name');

if (empty($listings)) {
return false;
}

$this->calc = $dbcount ?: $this->getRow("SELECT FOUND_ROWS() AS `calc`", 'calc');

$type = $rlListingTypes->types[$listing_type];

if ($type['Cat_general_only']) {
$shortFormFields = $this->getFormFields($type['Cat_general_cat'], 'short_forms', $listing_type);
$this->getFormFields($type['Cat_general_cat'], 'listing_titles', $listing_type);
}

foreach ($listings as &$listing) {
$rlCommon->listings[$listing['ID']] = $listing;

if (!$shortFormFields) {
$shortFormFields = $this->getFormFields(
$listing['Category_ID'],
'short_forms',
$listing['Listing_type'],
$listing['Parent_IDs']
);
}

$listingFields = $shortFormFields;

foreach ($listingFields as &$field) {
$field['value'] = $rlCommon->adaptValue(
$field,
$listing[$field['Key']],
'listing',
$listing['ID'],
true,
false,
false,
false,
$listing['Account_ID'],
null,
$listing['Listing_type']
);
}

$listing['fields'] = $listingFields;
$listing['listing_title'] = $this->getListingTitle(
$listing['Category_ID'],
$listing,
$listing['Listing_type'],
false,
$listing['Parent_IDs']
);
$listing['url'] = $this->getListingUrl($listing);

unset($field, $listingFields);
}

return $listings;


Thanks Rudi,

I just tried this solution instead and it does work.