PHP Notice: Undefined offset: 1
1.5.7c
PHP 7.2
Edit Orders 4.6.0
Twitch Hidden Model for 1.5.7c
My log file keeps filling up with the below listed error. Any assistance would be greatly appreciated.
PHP Notice: Undefined offset: 1 in /includes/functions/functions_email.php on line 140
Code:
135 // clean up currencies for text emails
136 $zen_fix_currencies = preg_split("/[:,]/" , str_replace(' ', '', CURRENCIES_TRANSLATIONS));
137 $size = sizeof($zen_fix_currencies);
138 for ($i=0, $n=$size; $i<$n; $i+=2) {
139 $zen_fix_current = $zen_fix_currencies[$i];
140 $zen_fix_replace = $zen_fix_currencies[$i+1];
141 if (strlen($zen_fix_current)>0) {
142 while (strpos($email_text, $zen_fix_current)) $email_text = str_replace($zen_fix_current, $zen_fix_replace, $email_text);
143 }
144 }
Re: PHP Notice: Undefined offset: 1
If you go to your admin, then configuration and Email... What is the setting for the item titled: 'Convert Currencies for Text Emails'?
Re: PHP Notice: Undefined offset: 1
Quote:
Originally Posted by
mc12345678
If you go to your admin, then configuration and Email... What is the setting for the item titled: 'Convert Currencies for Text Emails'?
It is blank
Re: PHP Notice: Undefined offset: 1
Quote:
Originally Posted by
wsworx
It is blank
To me that seems unusual and likely is why the log is being generated. A default install includes at least two if not three+ pre-existing items in that list. The absence of data may be causing some other value to be returned which is resulting in entering that loop with only one record not two to evaluate.
Of course one question is what was done to clear that entry/why is it blank instead of the default. (posting tips answers may reveal some of that otherwise may also have a concern of *who* cleared it.)
I don't have the answer at the moment of what the expected/default data is. For assistance to all readers it will be good to include and if someone else doesn't I will try to look it up and post here especially if you don't find/report those values.
Re: PHP Notice: Undefined offset: 1
Funny, I am chasing the exact same error. Same symptom, same blank setting in email preferences. I did not knowingly change the default setting so I have no idea how it was wiped out. I went to a clean unmodified version of zc157c and copied the default setting from the database:
Code:
£,£:€,€:®,®:™,™
I hope copy and paste works.
Dave
Re: PHP Notice: Undefined offset: 1
Thanks for the hint mc12345678!
Re: PHP Notice: Undefined offset: 1
Perhaps that block of code (lines 136-144) in functions_email.php should be bypassed if CURRENCIES_TRANSLATIONS is empty. In the next zc version???
Dave
Re: PHP Notice: Undefined offset: 1
Quote:
Originally Posted by
Dave224
Perhaps that block of code (lines 136-144) in functions_email.php should be bypassed if CURRENCIES_TRANSLATIONS is empty. In the next zc version???
Dave
I was somewhat thinking the same thing, but also thinking why would/should it be empty? The proposed ZC defaults appear to be that way because they are needed. There may be others that could be useful to other users, but it seems that there should always at least be the reg and trademark characters. The euro and pound symbols may for some/many be extraneous; however, they are definitely known to be an issue.
So an important thing here and to potentially address this is to try to identify some commonalities that may have caused this. Please, for those that have arrived here, until an additional request has been made for information, could you provide an indication of database history and install/upgrade "process"? As identified a default install with a base fileset has values here.
The minimal information requested could potentially help those of the core team address this or possibly some other not yet known related issue...
Re: PHP Notice: Undefined offset: 1
I don't have a detailed history of my database, but in general, the zc157c database began way back in zc151, then zc155, then zc155f, and finally to the zc157 series. The database from the previous version was copied to the new version, and then the database update process in the install script was run. In my case, between two updates, the database got scrambled at least once and had to be repaired/restored from backup. The database was modified as new products/categories and plugins/custom coding were added. I might have changed the default value because the description of the configuration variable (CURRENCIES_TRANSLATIONS) describes currencies like the pound or euro which are not applicable to our store. We only deal with English and Dollars. IMHO, it might be less tempting to delete the default if the description was more generic like "html special character entities to symbol translations for text emails", with examples that included currencies, registration mark, trade mark, and other special characters. But I still feel the code should protect itself from "bad" user inputs, especially those input values which create PHP notices or errors.
Re: PHP Notice: Undefined offset: 1
Quote:
Originally Posted by
Dave224
Perhaps that block of code (lines 136-144) in functions_email.php should be bypassed if CURRENCIES_TRANSLATIONS is empty. In the next zc version???
Dave
Done! https://github.com/zencart/zencart/c...344184969e218d
Re: PHP Notice: Undefined offset: 1
Psst. Unless have utterly and completely modified the database to rid it of its history, the database "history" can be found when clicking the version link in the admin. After seeing several of the "settings" the history for that database can be found.
Huh, and I was going to suggest that this might be one of those conditions where it may actually be good to have logs generated because of the relatively limited expectation of just clearing database entries "because" and it possibly being a "marker" that someone has done something undesirable. But, then again, why let someone else cause a problem with the store just because they found some "issue"... :)
Ah well. :P thanks to those that identified an issue. For others, seems it may still be good to identify how this issue was risen...
Re: PHP Notice: Undefined offset: 1
Well, you learn something new everyday! Thanks, mc12345678. FWIW here's the database version history:
Zen Cart 1.5.7c
Database Patch Level: 1.5.7
v1.5.7 [2020-10-09 10:23:35] (Version Update 1.5.6->1.5.7)
v1.5.6c [2020-10-09 10:23:34] (Version Update 1.5.5->1.5.6c)
v1.5.5f [2019-01-21 07:46:06] (Version Update 1.5.4->1.5.5f)
v1.5.4 [2019-01-21 07:46:05] (Version Update 1.5.3->1.5.4)
v1.5.3 [2019-01-21 07:46:05] (Version Update 1.5.2->1.5.3)
v1.5.2 [2019-01-21 07:46:04] (Version Update 1.5.1->1.5.2)
v1.5.1 [2019-01-21 07:46:03] (Version Update 1.5.0->1.5.1)
v1.5.0 [2012-06-14 15:20:17] (Fresh Installation)
v1.5.0 [2012-06-14 15:20:17] (Fresh Installation)
And thank you Dr. Byte!