Problem/Motivation
After deploying the 2.11 release, some pages begun resulting in 503 server error. I suspect those pages don't have the date field value selected, but could be something else. We use search API page which resulted in this error returning back for any keyword.
Steps to reproduce
Steps to reproduce may be specific to our environment/set up.
THe error returned is:
TypeError: Argument 7 passed to date_formatter_process() must be of the type array, null given, called in docroot/sites/all/modules/contrib/date/date.field.inc on line 205 in date_formatter_process() (line 221 of docroot/sites/all/modules/contrib/date/date.module)
Upon inspection, there was a change in the function date_formatter_process() arguments - added type, which is now causing the problem when an incorrect type was passed.
Proposed resolution
Proposing the addition of data type validation. A patch which resolved the issue on our side attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | date-n3206507-14.patch | 524 bytes | damienmckenna |
| #8 | date-n3206507-8.patch | 519 bytes | damienmckenna |
| date_formatter_error.patch | 637 bytes | ivrh |
Issue fork date-3206507
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3206507-typeerror-argument-7
changes, plain diff MR !2
Comments
Comment #4
drupal-kata commentedWe faced the same problem: Drupal 7.81, MYSQL 5.7 and PHP 7.3. We got 503 error in the views where the date field was empty. The patch worked and helped to solve the problem.
Comment #8
damienmckennaRerolled.
Comment #9
damienmckennaI'm not sure this should be needed - $items should be an array of arrays, with each item containing an element 'value', per hook_field_formatter_view(). So I wonder if the error comes from somewhere else, or maybe some custom code that modifies the array?
Comment #10
damienmckennaIf someone can provide some specifics on what triggers this, e.g. another module that uses date fields, or maybe some custom code, then I'm happy to work on finishing this off, but right now the module seems to work as it's supposed to.
Comment #11
damienmckennaComment #12
xmacinfoI am hitting that error updating the Date module from 7.x-2.10 to 7.x-2.14.
TypeError: Argument 7 passed to date_formatter_process() must be of the type array, null given, called in /srv/www/………/sites/all/modules/date/date.field.inc on line 215 in date_formatter_process() (line 223 of /srv/www/………/sites/all/modules/date/date.module).We have a lot of custom code.
Not sure if I will use the patch in #8 or if I will be able to investigate the piece of code that triggers that error.
Comment #13
damienmckennaPatch #8 wasn't compatible with PHP 5, so this might work better.
Comment #14
damienmckennaNever mind #13, this is what I meant.
Comment #15
damienmckenna@xmacinfo: Could you please do some debugging to see if you can work out what variable is causing this?
Comment #16
xmacinfo@DamienMcKenna Using your patch in #15 solves the issue.
We have a lot of custom code. I will try to find which variable is passed as an argument (argument 7). But I am not sure how much time I will be able to allow for this.