joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.76k stars 3.64k forks source link

HTMLHelper::_('calendar') is broken on Joomla 4 RC5 #34948

Closed nikosdion closed 3 years ago

nikosdion commented 3 years ago

Steps to reproduce the issue

Anywhere in your view template add one of these two lines:

HTMLHelper::_('calendar', '', 'foobar', 'foobar', '%Y-%m-%d', array('class' => 'input-small'));
HTMLHelper::_('calendar', '2021-07-28 12:25:15', 'foobar', 'foobar', '%Y-%m-%d', array('class' => 'input-small'))

Expected result

You see a calendar field

Actual result

Two warnings and an exception.

Warning: Undefined variable $firstday in .../layouts/joomla/form/field/calendar.php on line 106
Warning: Undefined variable $weekend in .../layouts/joomla/form/field/calendar.php on line 107

Exception: implode(): Argument #1 ($pieces) must be of type array, string given File layouts/joomla/form/field/calendar.php Line 107

Trace:

#0 .../layouts/joomla/form/field/calendar.php(107): implode(',', NULL)
#1 .../libraries/src/Layout/FileLayout.php(128): include('/Users/nicholas...')
#2 .../libraries/src/Layout/LayoutHelper.php(73): Joomla\CMS\Layout\FileLayout->render(Array)
#3 .../libraries/src/HTML/HTMLHelper.php(1219): Joomla\CMS\Layout\LayoutHelper::render('joomla.form.fie...', Array, NULL, NULL)
#4 .../libraries/src/HTML/HTMLHelper.php(322): Joomla\CMS\HTML\HTMLHelper::calendar('2000-01-01 00:0...', 'from', 'from', '%Y-%m-%d', Array)
#5 .../libraries/src/HTML/HTMLHelper.php(194): Joomla\CMS\HTML\HTMLHelper::call(Array, Array)

System information (as much as possible)

Environment

Item Value
Operating System (reported by PHP) Darwin
PHP version (as reported by your server) 8.0.7
PHP Built On Darwin MYLAPTOPNAME 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
PHP SAPI fpm-fcgi
Server identity Apache/2.4.48 (Unix) OpenSSL/1.1.1k
Browser identity Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15
Joomla! version 4.0.0-rc5
Database driver name mysqli
Database driver type mysql
Database server version 8.0.25
Database collation utf8mb4_unicode_ci
Database connection collation utf8mb4_0900_ai_ci
PHP Memory limit 128M
Peak Memory usage 7.83M
PHP Timeout (seconds) 30

PHP Settings

Item Value
memory_limit 128M
upload_max_filesize 128M
post_max_size 80M
display_errors 1
short_open_tag  
file_uploads 1
output_buffering 1
open_basedir  
session.save_path  
session.auto_start 0
disable_functions  
xml 1
zlib 1
zip 1
mbstring 1
gd 1
iconv 1
intl 1
max_input_vars 1000

Additional comments

This does not happen when using the calendar form field.

However, HTMLHelper is NOT deprecated, therefore this is a release blocker bug as it breaks something that's supposed to still work properly.

wilsonge commented 3 years ago

//cc @Fedik this will be related to https://github.com/joomla/joomla-cms/pull/34870

If you don't have time i'll look into it this evening. Apologies @nikosdion

nikosdion commented 3 years ago

My only problem is that this happened after I had spent my weekend testing everything manually and thoroughly with Joomla 4 RC5 (well, at least whatever was included in the 4.0-dev branch at this time) and released new versions on Monday, confident that they work fine. Now all pages with date inputs appear broken and people are filing bug reports to me.

FWIW I am changing my software to use an HTML5 datetime-local input which is far more user-friendly than Joomla's calendar field — and doesn't break all the freaking time.

Fedik commented 3 years ago

Yeah, after testing different langs I forgot to update HTMLHelper::calendar, there just missed a couple $data properties. I will check.

My only problem is that this happened after I had spent my weekend testing

All be good, no need to worry, no one deleting it.

FWIW I am changing my software to use an HTML5 datetime-local input

https://caniuse.com/?search=datetime-local

brianteeman commented 3 years ago

Also see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local and note that it only supports gregorian calendars while joomla has to support other calendars such as jalali

joomdonation commented 3 years ago

PR https://github.com/joomla/joomla-cms/pull/34949 should fix the issue.

nikosdion commented 3 years ago

@brianteeman I am pretty sure that my users prefer being able to manage their backups, the security of their site, their comments and their support tickets to seeing an error page because Joomla's more complete calendar is broken every second release. Before assuming that I don't care stop and think what is the impact of Joomla breaking the calendar field all the time vs using datetime-local. In the end of the day people care more about, dunno, restoring their backup when something doesn't work than they care about a localised calendar.

richard67 commented 3 years ago

Closing as having a pull request. Please test #34949 . Thanks in advance.