Skip to content
New issue

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

Error on frontend when File missing from Grid with Fluid field #3933

Closed
ic360-com opened this issue Dec 6, 2023 · 5 comments · Fixed by #3938
Closed

Error on frontend when File missing from Grid with Fluid field #3933

ic360-com opened this issue Dec 6, 2023 · 5 comments · Fixed by #3938

Comments

@ic360-com
Copy link

I'm getting the below error, when outputting a Fluid field, that contains a Grid containing a File in one of the Grid Fields, when no File has been selected/uploaded.


TypeError Caught
array_key_exists(): Argument #2 ($array) must be of type array, bool given
ee/ExpressionEngine/Addons/file/ft.file.php:787

Stack Trace: Please include when reporting this error
#0 ee/legacy/libraries/api/Api_channel_fields.php(391): File_ft->replace_tag_catchall()
#1 ee/legacy/libraries/Grid_parser.php(671): Api_channel_fields->apply()
#2 ee/legacy/libraries/Grid_parser.php(747): Grid_parser->call()
#3 ee/legacy/libraries/Grid_parser.php(486): Grid_parser->_replace_tag()
#4 ee/legacy/libraries/Grid_parser.php(370): Grid_parser->_parse_row()
#5 ee/ExpressionEngine/Addons/grid/ft.grid.php(231): Grid_parser->parse()
#6 ee/legacy/libraries/api/Api_channel_fields.php(391): Grid_ft->replace_tag()
#7 ee/ExpressionEngine/Model/Content/FieldFacade.php(423): Api_channel_fields->apply()
#8 ee/ExpressionEngine/Addons/fluid_field/Service/Tag.php(167): ExpressionEngine\Model\Content\FieldFacade->replaceTag()
#9 ee/ExpressionEngine/Addons/fluid_field/Service/Tag.php(140): ExpressionEngine\Addons\FluidField\Service\Tag->parsePairs()
#10 ee/legacy/libraries/Fluid_field_parser.php(434): ExpressionEngine\Addons\FluidField\Service\Tag->parse()
#11 ee/ExpressionEngine/Addons/fluid_field/ft.fluid_field.php(1064): Fluid_field_parser->parse()
#12 ee/legacy/libraries/api/Api_channel_fields.php(391): Fluid_field_ft->replace_tag()
#13 ee/legacy/libraries/channel_entries_parser/components/Custom_field_pair.php(183): Api_channel_fields->apply()
#14 ee/legacy/libraries/channel_entries_parser/Parser.php(291): EE_Channel_custom_field_pair_parser->replace()
#15 ee/legacy/libraries/Channel_entries_parser.php(172): EE_Channel_data_parser->parse()
#16 ee/ExpressionEngine/Addons/channel/mod.channel.php(2528): EE_Channel_parser->parse()
#17 ee/ExpressionEngine/Addons/channel/mod.channel.php(261): Channel->parse_channel_entries()
#18 ee/legacy/libraries/Template.php(1830): Channel->entries()
#19 ee/legacy/libraries/Template.php(1505): EE_Template->process_tags()
#20 ee/legacy/libraries/Template.php(624): EE_Template->tags()
#21 ee/legacy/libraries/Template.php(247): EE_Template->parse()
#22 ee/legacy/libraries/Template.php(177): EE_Template->fetch_and_parse()
#23 ee/legacy/libraries/Core.php(811): EE_Template->run_template_engine()
#24 ee/legacy/controllers/ee.php(53): EE_Core->generate_page()
#25 [internal function]: EE->index()
#26 ee/ExpressionEngine/Core/Core.php(268): call_user_func_array()
#27 ee/ExpressionEngine/Core/Core.php(124): ExpressionEngine\Core\Core->runController()
#28 ee/ExpressionEngine/Boot/boot.php(184): ExpressionEngine\Core\Core->run()
#29 index.php(164): require_once('...')
#29 index.php(164): require_once('...')

EE 7.3.14
PHP 8.1

@intoeetive
Copy link
Contributor

@ic360-com how does the template code look like? Are you using any modifiers on the file column? Chaining multiple modifiers?

Also, I think you could solve this for now by checking if column is not empty prior to displaying it

@ic360-com
Copy link
Author

Yes... I'm using that workaround. 👍

The template code is like this (without the workaround):

{main:layout3}
	{content}
		<div class="row mt-5">
			<div class="col-md-7 pe-md-5">
				{content:text}
			</div>
			<div class="col-md-5">
				<img src="{content:image:file:resize:webp resize:width="480"}" alt="{content:alt}">
				{if content:alt}<p class="image-caption">{content:alt}</p>{/if}
			</div>
		</div>
	{/content}
{/main:layout3}```

@intoeetive
Copy link
Contributor

@ic360-com I don't think your setup is completely clear to me

So the Fluid is main, which has Grid of layout3, which has text, image and alt columns, is that correct? If yes, what is the :file modifier that you're using before :resize? I feel like it should be just {content:file:resize:webp resize:width="480"} or {content:image:resize:webp resize:width="480"}?

@ic360-com
Copy link
Author

Yes you're correct.
So I've tried removing the 'file' modifier and it works fine.
Sorry my error.

@intoeetive
Copy link
Contributor

If you ask me how I knew that... ;) #3766

But again, the error should not be shown even when applying invalid modifier. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants