XoopsModules25x / adslight

Adslight is a classifieds module that allow users of XOOPS website to advertise items for sale, exchange or barter.
5 stars 6 forks source link

Ads view errors #12

Closed cesagonchu closed 3 years ago

cesagonchu commented 4 years ago

When i create an ad and go to the view (adslight/viewads.php?lid=1) i get these errors:

Notice: Undefined variable: xoopsModuleConfig in file /include/comment_view.php line 27

Notice: Trying to access array offset on value of type null in file /include/comment_view.php line 27

Notice: Trying to access array offset on value of type bool in file /modules/adslight/class/Utility.php line 711

Warning: implode(): Invalid arguments passed in file /modules/adslight/class/Utility.php line 715


My config: PHP 7.4.9 MYSQL 5.7.31-0ubuntu0.16.04.1 XOOPS 2.5.11-Beta1

cesagonchu commented 3 years ago

A user would need this module, so I tested it again. I still have exactly the same errors (see above), with the latest version of Xoops and the latest version of the Adslight module.


My config:

Apache/2.4.18 (Ubuntu) PHP version 7.4.9 MySQLi extension mysqlnd 7.4.9

mambax7 commented 3 years ago

This should be fixed now in RC4. Please re-open if there is still a problem. I've made some changes related to currency, and I'm curious if it looks OK in the French environment with Euro showing properly in the price view.

Well, this module needs to be rewritten and cleaned-up. Maybe it's time for version 3.0 ?

cesagonchu commented 3 years ago

I tried on a new fresh install of Xoops 2.5.11 and I still get 2 out of the 4 errors:

Notice: Trying to access array offset on value of type bool in file /modules/adslight/class/Utility.php line 711
Warning: implode(): Invalid arguments passed in file /modules/adslight/class/Utility.php line 715

Clarification, I submitted an ad on the user side.

mambax7 commented 3 years ago

So far I can't reproduce it... http://demo.xoops.org/modules/adslight/viewads.php?lid=2

cesagonchu commented 3 years ago

I don't know, maybe we don't have the same config.

image

image


PHP 7.4.9 MYSQL 5.7.33-0ubuntu0.16.04.1 XOOPS 2.5.11-Beta2 Apache/2.4.18 (Ubuntu)

montuy337513 commented 3 years ago

any of the very variables return a false mb_strlen ($ prefix) + mb_strlen ($ currency) + mb_strlen ($ value [0])

This is the management of the thousands point on line 708 or 709

finally, only the Europeans, outside the UK, will have this problem

mambax7 commented 3 years ago

Your price is obviously not going through, as it is empty, while on our Demo site, we have: image

In Utility.php, around line 649, can you change to this and see if it makes any difference?

//        setlocale(LC_ALL, 'en_US');
        setlocale(LC_ALL, 'fr_FR');
        setlocale(LC_NUMERIC, 'C');

When I do it on our Demo site, I'm getting the Euro formatting:

image

Also, are you using Linux or Windows on your test site?

cesagonchu commented 3 years ago

I guess it appears empty because of the errors. If you look at the bottom of this image, you'll see that I filled in the price correctly (which is required in the field).

image

cesagonchu commented 3 years ago

Normally, since I am with an English Xoops, I would not have this as a default in the module preferences: EUR €

image

mambax7 commented 3 years ago

Yes, I understand it, but can you make the suggested changes in Utility.php, around line 649, and see if it makes a difference?


//        setlocale(LC_ALL, 'en_US');
        setlocale(LC_ALL, 'fr_FR');
        setlocale(LC_NUMERIC, 'C');

It might be the best if you email me access to your site so I can test it directly there...

mambax7 commented 3 years ago

On our Demo site, we have an English version and these settings: image and with commented out all in Utility.php:

     //   setlocale(LC_ALL, 'en_US');
     //   setlocale(LC_ALL, 'fr_FR');
     //   setlocale(LC_NUMERIC, 'C');

I'm still getting US$ formatting, but at least it is visible:

image

cesagonchu commented 3 years ago

Sorry, this is still not the solution. Thanks for trying :) I have the same errors but since I made your modification, they just changed numbers:

Notice: Trying to access array offset on value of type bool in file /modules/adslight/class/Utility.php line 712
Warning: implode(): Invalid arguments passed in file /modules/adslight/class/Utility.php line 716

The price is still not displayed.

mambax7 commented 3 years ago

I'll need access to your installation to test some ideas...

cesagonchu commented 3 years ago

with commented out all in Utility.php:

     //   setlocale(LC_ALL, 'en_US');
     //   setlocale(LC_ALL, 'fr_FR');
     //   setlocale(LC_NUMERIC, 'C');

I get the same errors. However I uninstalled the module, I deleted the files in uploads and I cleared the caches by maintenance.

cesagonchu commented 3 years ago

Okay, we'll do this tomorrow because I'm very tired. Transifex gave me a headache :p

montuy337513 commented 3 years ago

Line 710, var_dump($prefix); var_dump($currency); var_dump($value[0]); that should give you 3 raw results ( int or string). If we have a bool, we will have found the winner

mambax7 commented 3 years ago

Based on the error "Notice: Trying to access array offset on value of type bool" it has to be $value because that's the only one that is being accessed as an array: $value[0]

montuy337513 commented 3 years ago

in line 710 if(!is_array($value)) OR !array_key_exists(0,$value) ) { $value[0] = 0; } that should bypass the error. I'm in the car, it's not easy to write properly

mambax7 commented 3 years ago

Well, I still need to get access to cesagonchu's installation to understand why do we have this error in the first place. We have both English installation, but she has the error but I don't. Once we understand it, then we can test different solutions, like the one that you suggested above. Right now it's like walking in the dark :)

mambax7 commented 3 years ago

I just created a new function that does the formatting, which should be easier to manage: formatCurrencyTemp() Please download the code directly from https://github.com/mambax7/adslight for testing. In the meantime, I'll keep doing cleanup and refactoring...

cesagonchu commented 3 years ago

Now I can see the price but when I go to modules/adslight/members.php?usid=1 I get these errors:

Notice: Trying to access array offset on value of type bool in file /modules/adslight/class/Utility.php line 710
Warning: implode(): Invalid arguments passed in file /modules/adslight/class/Utility.php line 714

I'll send you an email so you can see all this.

Thanks! ;)

cesagonchu commented 3 years ago

And I can no longer add images to the ad.

mambax7 commented 3 years ago

OK, the issue seems to be fixed now - the problem that you had, and which I was not able to reproduce was because I had English prices and English decimal points, so it worked, while you had French prices and English decimal points, so there was a mismatch: image

It should work now. Let me know if you see anything else...