Currency php on line 141warning division by zero in

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Currency bug is not resolved #7981

Currency bug is not resolved #7981

Comments

What version of OpenCart are you reporting this for?
3.0.3.3

Describe the bug
A clear and concise description of what the bug is:
Returned value has a problem, since the cURL call fails (url doesn’t exists)

What section does it affect? Admin Area (dashboard)
As already noticed, in admin/model/localisation/currency.php

To Reproduce
Steps to reproduce the behavior:

  1. Go to Admin Area (dashboard)
  2. In the top of the browser windows, appears: «Warning: A non-numeric value encountered in /path/to/docroot/opencartfolder/admin/model/localisation/currency.php on line 141Warning: Division by zero in /path/to/docroot/opencartfolder/admin/model/localisation/currency.php on line 141»

Expected behavior
A csv file to download with the correct data, instead the one taken from yahoo server (that is unavailable)

Server / Test environment (please complete the following information):

  • Local development
  • XUbuntu 20.04, 64 bit
  • PHP version 7.2
  • Apache version: 2.4.41
  • Browser(s) tested with [Firefox 77.0.1 and Chrome 83.0.4103.61)
Читайте также:  Логотип для css команды

The text was updated successfully, but these errors were encountered:

Источник

Warning: Division by zero in /home/www/vavavroum/admin/model/localisation/currency.php on line 141

Hi all,
back here after a while.
i’ve read the posts answering the same problem but, in my case, php7.0 or 7.1 i’ve got this issue with just opencart 3.0.3.1 installed and working, no extension added
a quick look into the file (currency.php) and, funny enough, it still rely on a yahoo service known to have stopped working a while ago.
of course i’ll try the patch extension to see if it works (no said to work with the last release but well the file itself hasn’t changed from previous releases) but i do think it’s funny the system hasn’t changed
just my two cents

Re: Warning: Division by zero in /home/www/vavavroum/admin/model/localisation/currency.php on line 141

Post by IP_CAM » Wed Apr 03, 2019 11:04 am

Well, it’s possibly one of the 215 Pull requests, and so still might
take a while, to then one day be part of a next Release, I assume.
And as long as it comes for free, there is nothing to complain about .
The way, as I look at it at least.
Ernie

My Github OC Site: https://github.com/IP-CAM
5’000 + FREE OC Extensions, on the World’s largest Github OC Repository Archive Site.

Re: Warning: Division by zero in /home/www/vavavroum/admin/model/localisation/currency.php on line 141

Post by virtualgadjo » Wed Apr 17, 2019 5:10 pm

hi IP_CAM,
thanks for your answer and sorry for the late reply but, athought i subscribed to the thread i haven’t received any notification for your answer.

first of all, i don’t complain at all, i just say it»s a bit funny

and what’s important to me, you may have guessed, due to my english. that i’m french and, as a french guy, i do fight to make clients use opencart instead of its huge competitor, prestashop, because i do like it far more and, as you probably know, prestashop is free too so when i say «guys, i think it’s a better idea to use opencart, simpler, easier to understand, lighter and so on» (and should i add, with the help of the fabulous guys who make journal theme — and, if you have a look at my previous messages, have helped solving another opencart little bug still alive in the core. — , so fantastic to customize) when it comes with an error as soon as you open the admin, i have to fight even more

Читайте также:  Python match regex groups

last thing, yes opencart is free but i don’t hesitate a second to buy myself and have my client buy extensions that are not and help the opencart guys make a living out of it, i perfectly understand the business model

well let’s see how this goes and, in the meantime, thanks again for taking time to answer and be reassured, once more, i do not complain at all, i just add my two cents hoping that cents after cents, it helps coping wooner with this little issue

Источник

New Install, Divide by zero error?

I’ve read that this has something to do with a yahoo finance service being discontinued and an improperly handled CURL value? and that this has something to do with my PHP version? I have PHP 7.3.6 in my production web host.

Is there a fix or work around to get rid of this error? I read it «Disabling the auto update currency fixes it» but I don’t seem to have that plugin enabled.
Also I read «This bug was fixed on the main fork» at https://github.com/opencart/opencart/issues/7476 but that doesn’t seem to be the case.

Is there an easy way to get this working without error? I’ve looked at the line of code in the currency PHP file and I have no idea what I might need to do to address this. seems like I am more likely to break something If i willy nilly start trying to add boundary case varible checking here. («If value is non-numerical set to «)
***********************************

$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $currency_data) . '&f=sl1&e=.json'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $content = curl_exec($curl); curl_close($curl); $line = explode("\n", trim($content)); for ($i = 0; $i < count($line); $i = $i + 2) < $currency = utf8_substr($line[$i], 4, 3); $value = utf8_substr($line[$i], 11, 6); if ((float)$value < 1 && isset($line[$i + 1])) < $value = (1 / utf8_substr($line[$i + 1], 11, 6)); >if ((float)$value) < $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'"); > > 

Last edited by straightlight on Wed Apr 15, 2020 8:04 am, edited 1 time in total.
Reason: Please add the code tags!

Источник

Читайте также:  Php поиск строки между символами

warning after fresh installation

after a fresh installation of OpenCart 3.0.3.6 i get a warinig in de admin dashboard.

I tried searching the forum but cannot find a solution.

Warning: A non-numeric value encountered in /v**********/admin/model/localisation/currency.php on line 141Warning: Division by zero in /var/***********/admin/model/localisation/currency.php on line 141Warning: A non-numeric value encountered in /v*****/admin/model/localisation/currency.php on line 141Warning: Division by zero in /v***/admin/model/localisation/currency.php on line 141Warning: A non-numeric value encountered in /v***/admin/model/localisation/currency.php on line 141Warning: Division by zero in /v***/admin/model/localisation/currency.php on line 141

When i turn off disp[lay error everything works fine. So I think it’s not a big issue, but a little strange after fresh installation.

Re: warning after fresh installation

Post by khnaz35 » Fri Aug 28, 2020 8:56 pm

after a fresh installation of OpenCart 3.0.3.6 i get a warinig in de admin dashboard.

I tried searching the forum but cannot find a solution.

Warning: A non-numeric value encountered in /v**********/admin/model/localisation/currency.php on line 141Warning: Division by zero in /var/***********/admin/model/localisation/currency.php on line 141Warning: A non-numeric value encountered in /v*****/admin/model/localisation/currency.php on line 141Warning: Division by zero in /v***/admin/model/localisation/currency.php on line 141Warning: A non-numeric value encountered in /v***/admin/model/localisation/currency.php on line 141Warning: Division by zero in /v***/admin/model/localisation/currency.php on line 141

When i turn off disp[lay error everything works fine. So I think it’s not a big issue, but a little strange after fresh installation.

have you turned off the auto currency update in settings?

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature

Источник

Оцените статью