J3 Issue ?
avatar proweb
proweb
14 Nov 2017

Steps to reproduce the issue

Create field type=text, filter=Telephone
image

Then go to article and add phone in that field
image
Then Save it

Expected result

Field value with my numbers

Actual result

Field value has DOT before real field value
image

System information (as much as possible)

=============
System Information

php: Linux proweb 4.4.0-100-generic #123-Ubuntu SMP Thu Nov 2 10:16:13 UTC 2017 x86_64
dbversion: 5.7.20-0ubuntu0.16.04.1
dbcollation: utf8_general_ci
dbconnectioncollation: utf8mb4_general_ci
phpversion: 7.0.22-0ubuntu0.16.04.1
server: Apache/2.4.18 (Ubuntu)
sapi_name: apache2handler
version: Joomla! 3.8.2 Stable [ Amani ] 7-November-2017 15:00 GMT
platform: Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
useragent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36

=============
PHP Settings

safe_mode: false
display_errors: true
short_open_tag: false
file_uploads: true
magic_quotes_gpc: false
register_globals: false
output_buffering: true
open_basedir:
session.save_path: xxxxxx
session.auto_start: 0
disable_functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
xml: true
zlib: true
zip: true
mbstring: true
iconv: true
max_input_vars: 10000

Additional comments

avatar proweb proweb - open - 14 Nov 2017
avatar joomla-cms-bot joomla-cms-bot - change - 14 Nov 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Nov 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Nov 2017
Category com_fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Nov 2017
Status New Confirmed
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 14 Nov 2017

Issue confirmed.

System information

3.8.3-dev
Multilanguage Site
macOS Sierra, 10.12.6
Firefox 56 (64-bit)

MAMP 4.1.1

  • PHP 7.0.15
  • MySQLi 5.6.35
avatar brianteeman
brianteeman - comment - 14 Nov 2017

The relevant code is here

public static function tel($number, $displayplan)

Reading that it looks like the expected behaviour but I really cant tell

avatar proweb
proweb - comment - 15 Nov 2017

So as I see in code:

@param   integer  $number       The integers in a phone number with dot separated country code
	 *                                 ccc.nnnnnnn where ccc represents country code and nnn represents the local number.

How we should know about it? Where is documentation? In different countries phone nubmers write different. We for example don't use dots in phone number

So how I must to know in which format I need to write phone number if it's nowhere written... Only in code! Very "user-friendly"...

avatar brianteeman
brianteeman - comment - 15 Nov 2017

Reading the code it looks like it is an official International Telephone specification. However I agree that it is not a format that would be used in the UK either. To be honest what I would do is just to exclude the filter. Its not needed and it doesnt really help

avatar brianteeman brianteeman - change - 25 Mar 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar brianteeman
brianteeman - comment - 6 Apr 2018

I am going to close this. The filter is working as intended. Its just not very useful

avatar brianteeman brianteeman - change - 6 Apr 2018
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2018-04-06 12:36:32
Closed_By brianteeman
avatar brianteeman brianteeman - close - 6 Apr 2018
avatar infograf768
infograf768 - comment - 6 Apr 2018

It seems the code in https://github.com/joomla/joomla-cms/blob/54eb5d8cea29b064c2ad2122e15e71d478c60b01/libraries/cms/html/tel.php#L34 is not applied in this case.

We have there

	public static function tel($number, $displayplan)
	{
		$number = explode('.', $number);
		$countrycode = $number[0];
		$number = $number[1];
		if ($displayplan === 'ITU-T' || $displayplan === 'International' || $displayplan === 'int' || $displayplan === 'missdn' || $displayplan == null)
		{
			$display[0] = '+';
			$display[1] = $countrycode;
			$display[2] = ' ';
			$display[3] = implode(str_split($number, 2), ' ');
		}

for the default format ITU-T

which should give, if entered as
33.4577729624
the following result
+33 4577729624

As it is not the case (tested here: we get 33.4577729624), I guess we do have an issue with that filter.

I suggest to reopen.

avatar fred-the-coder
fred-the-coder - comment - 19 Jul 2020

I do agree with infograf768.
On top of that, why having a not useful filter??

avatar infograf768
infograf768 - comment - 19 Jul 2020

In fact, issue may come from
https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Form/Form.php#L1466-L1544

The result does not come from public static function tel() as stated above as I can't find where this method is used in core.

avatar infograf768
infograf768 - comment - 19 Jul 2020

I'm reopening this as the filter is not only not working but gives wrong results (3.9.20 / staging)

avatar infograf768 infograf768 - change - 19 Jul 2020
Status Closed New
Closed_Date 2018-04-06 12:36:32
Closed_By brianteeman
avatar infograf768 infograf768 - reopen - 19 Jul 2020
avatar infograf768
infograf768 - comment - 19 Jul 2020

Looks like, unless someone totally rewrites that code, that we should take off the Telephone filter from these files:

/plugins/fields/repeatable/params/repeatable.xml:63: 									value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/text/params/text.xml:21: 				<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/text/text.xml:40: 					<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/textarea/params/textarea.xml:47: 				<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/textarea/textarea.xml:68: 					<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
avatar laoneo
laoneo - comment - 19 Jul 2020

Not sure why you tagged me, but if the filter is not correct. Then at least remove it in com_fields. Keep in mind about the upgrade of the existing filters, need to be unset in the existing fields.

avatar infograf768
infograf768 - comment - 19 Jul 2020

@laoneo
I tagged you because you introduced these filters in fields a long while ago #14403.
The filter is defined in JForm. I have seen nowhere in code the use of filter="tel"
Contact is using a simple text field.

No idea where I would unset the filter (after deleting the option in the plugins). Can you help?

avatar laoneo
laoneo - comment - 19 Jul 2020

Deleting the option would be enough, more difficult is the update of fields which have this filter set in the params on existing sites.

avatar infograf768
infograf768 - comment - 20 Jul 2020

I doubt anybody has ever used that filter, taking into account that it is really broken, but would it make sense to add in an sql update some code that would just change filter="tel" by filter="text" in every occurrence of fieldparams in db fields table?

Here the export of such a field.
(25, 3287, 'com_content.article', 0, 'Telephone field', 'telephone-field', 'Telephone field', '', 'text', '', '', 1, 0, 800, '2020-07-19 14:59:22', 0, '{\"hint\":\"\",\"class\":\"\",\"label_class\":\"\",\"show_on\":\"\",\"render_class\":\"\",\"showlabel\":\"1\",\"label_render_class\":\"\",\"display\":\"2\",\"layout\":\"\",\"display_readonly\":\"2\"}', '{\"filter\":\"tel\",\"maxlength\":\"\"}', '*', '2020-07-19 10:13:47', 800, '0000-00-00 00:00:00', 0, 1);

By using

UPDATE `#__fields` SET `fieldparams` = REPLACE(`fieldparams`, '"filter":"tel"', '"filter":"text"');

we correct db.

What do you think?

avatar laoneo
laoneo - comment - 20 Jul 2020

Looks good for me. Perhaps you want to add in the update statement a where clause "type='text'".

avatar richard67
richard67 - comment - 20 Jul 2020

By using

UPDATE `#__fields` SET `fieldparams` = REPLACE(`fieldparams`, '"filter":"tel"', '"filter":"text"');

we correct db.

What do you think?

@infograf768 The replacement should work and be safe, since both the search string and the replace string contain the complete name value pair, including the double quotes. We only had problems in past when this was not the case so that substrings were matching, too, where it was not desired.

But maybe the context column should be limited to certain values so that we cover only fields used for the core, i.e. add a

 WHERE `context` IN ('com_content.article', ...)

to the update statement?

avatar laoneo
laoneo - comment - 20 Jul 2020

Please do NOT add the context clause as it belongs to all fields, not only the ones from articles. But the filter is only applied to text fields, so you can limit it there.

avatar richard67
richard67 - comment - 20 Jul 2020

Ok, so a

WHERE `type` = 'text'

should be added.

avatar infograf768
infograf768 - comment - 20 Jul 2020

In fact we also have for repeatable/textarea another format. therefore

`WHERE `type` = 'text'`

is not enough.
{"fields":{"fields0":{"fieldname":"a form fields name","fieldtype":"textarea","fieldfilter":"tel"}}}

avatar richard67
richard67 - comment - 20 Jul 2020

Sure, then its an IN list with a few types.

avatar infograf768
infograf768 - comment - 20 Jul 2020

@richard67
for sql update:

3 types concerned
text
textarea
repeatable

2 formats of fieldparams
filter="tel" => filter="text"
fieldfilter="tel" => fieldfilter="text"

Option to delete in 5 files

/plugins/fields/repeatable/params/repeatable.xml:63: 									value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/text/params/text.xml:21: 				<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/text/text.xml:40: 					<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/textarea/params/textarea.xml:47: 				<option value="tel">JLIB_FILTER_PARAMS_TEL</option>
/plugins/fields/textarea/textarea.xml:68: 					<option value="tel">JLIB_FILTER_PARAMS_TEL</option>

Can you do the patch? I'm not familiar with IN

avatar richard67
richard67 - comment - 20 Jul 2020

@infograf768 The 2 formats "filter" and "fieldfilter" can happen with all the 3 types?

avatar infograf768
infograf768 - comment - 20 Jul 2020

Looks like fieldfilter is only for repeatable

/plugins/fields/repeatable/params/repeatable.xml:34: 								name="fieldfilter"
/plugins/fields/repeatable/repeatable.php:69: 			if (isset($formField->fieldfilter))
/plugins/fields/repeatable/repeatable.php:71: 				$child->addAttribute('filter', $formField->fieldfilter);
avatar richard67
richard67 - comment - 20 Jul 2020

Is filter then only for text and textarea?

avatar infograf768
infograf768 - comment - 20 Jul 2020

It looks like indeed

avatar richard67
richard67 - comment - 20 Jul 2020
UPDATE `#__fields` SET `fieldparams` = REPLACE(`fieldparams`, '"filter":"tel"', '"filter":"text"') WHERE `type` IN ('text', 'textarea');
UPDATE `#__fields` SET `fieldparams` = REPLACE(`fieldparams`, '"fieldfilter":"tel"', '"fieldfilter":"text"') WHERE `type` = 'repeatable';

Does that look right? If yes, please do you do the PR, @infograf768 ... I have too little time now.

avatar infograf768
infograf768 - comment - 20 Jul 2020

OK, will do.

avatar infograf768
infograf768 - comment - 20 Jul 2020

Closing as we have patch #30142

Needs sql update for postgresql and sqlazure

avatar infograf768 infograf768 - close - 20 Jul 2020
avatar infograf768 infograf768 - change - 20 Jul 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-07-20 08:18:47
Closed_By infograf768

Add a Comment

Login with GitHub to post a comment