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

Update AbstractTags.php #45

Closed
wants to merge 1 commit into from

Conversation

MoniqueHahnefeld
Copy link

catch an error if array key isn't set. the error show up when I save a model.

catch an error if array key isn't set. the error show up when I save a model.
@discordier
Copy link
Member

Could you fix the code style issues and author validation please? See travis build log.

@MacKP
Copy link

MacKP commented Nov 4, 2015

Works for me. @MoniqueHahnefeld can you pls fix the code style etc. so we can merge this PR?
regards

@discordier discordier added the bug label Nov 4, 2015
@discordier discordier added this to the 2.0.0 milestone Nov 4, 2015
@MoniqueHahnefeld
Copy link
Author

hey @MacKP
which code style I have to use please :D ?

@discordier
Copy link
Member

phpcq

@MoniqueHahnefeld
Copy link
Author

yes ok I will check this with phpcq next time.

@MoniqueHahnefeld
Copy link
Author

@discordier @MacKP Sorry but i don't know when I going to optimize this code. Maybe you can do this or simply take over the lines?

@discordier
Copy link
Member

After a second thought, I wonder how the original problem is even possible.
@MoniqueHahnefeld can you elaborate how you ran into this usecase?

@MoniqueHahnefeld
Copy link
Author

The problem was that I had an tags attribute which keys in the checkbox was id. After add many items in the backend I changed the key in the settings of the tags attribute from id to alias.

Then the problem, say the error appear when I open an entry mask of one of the items in the Backend.

This was the error:

Warning: array_key_exists() expects parameter 2 to be array, null given in composer/vendor/metamodels/attribute_tags/src/MetaModels/Attribute/Tags/AbstractTags.php on line 385
#0 [internal function]: __error(2, 'array_key_exist...', '/www/xxx...', 385, Array)
#1 composer/vendor/metamodels/attribute_tags/src/MetaModels/Attribute/Tags/AbstractTags.php(385): array_key_exists('tag_value_sorti...', NULL)
#2 composer/vendor/metamodels/attribute_tags/src/MetaModels/Attribute/Tags/AbstractTags.php(439): MetaModels\Attribute\Tags\AbstractTags->setDataForItem(1, Array, Object(Contao\Database\Mysqli\Result))
#3 composer/vendor/metamodels/core/src/MetaModels/MetaModel.php(887): MetaModels\Attribute\Tags\AbstractTags->setDataFor(Array)
#4 composer/vendor/metamodels/core/src/MetaModels/MetaModel.php(923): MetaModels\MetaModel->saveAttribute(Object(MetaModels\Attribute\Tags\MetaModelTags), Array, Array, 'de')
#5 composer/vendor/metamodels/core/src/MetaModels/MetaModel.php(1003): MetaModels\MetaModel->updateVariants(Object(MetaModels\Item), 'de', Array)
#6 composer/vendor/metamodels/core/src/MetaModels/Item.php(296): MetaModels\MetaModel->saveItem(Object(MetaModels\Item))
#7 composer/vendor/metamodels/core/src/MetaModels/DcGeneral/Data/Driver.php(585): MetaModels\Item->save()
#8 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Contao/View/Contao2BackendView/EditMask.php(615): MetaModels\DcGeneral\Data\Driver->save(Object(MetaModels\DcGeneral\Data\Model))
#9 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Contao/View/Contao2BackendView/EditMask.php(673): ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\EditMask->doPersist()
#10 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Contao/View/Contao2BackendView/BaseView.php(610): ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\EditMask->execute()
#11 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Contao/View/Contao2BackendView/BaseView.php(585): ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\BaseView->createEditMask(Object(MetaModels\DcGeneral\Data\Model), Object(MetaModels\DcGeneral\Data\Model), NULL, NULL)
#12 [internal function]: ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\BaseView->edit(Object(ContaoCommunityAlliance\DcGeneral\Action))
#13 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Contao/View/Contao2BackendView/BaseView.php(149): call_user_func_array(Array, Array)
#14 [internal function]: ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\BaseView->handleAction(Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent), 'dc-general.acti...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#15 composer/vendor/symfony/event-dispatcher/EventDispatcher.php(160): call_user_func(Array, Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent), 'dc-general.acti...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#16 composer/vendor/symfony/event-dispatcher/EventDispatcher.php(48): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'dc-general.acti...', Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent))
#17 composer/vendor/contao-community-alliance/dc-general/src/ContaoCommunityAlliance/DcGeneral/Controller/DefaultController.php(130): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('dc-general.acti...', Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent))
#18 composer/vendor/metamodels/core/src/MetaModels/BackendIntegration/Module.php(74): ContaoCommunityAlliance\DcGeneral\Controller\DefaultController->handle(Object(ContaoCommunityAlliance\DcGeneral\Action))
#19 system/modules/core/classes/Backend.php(423): MetaModels\BackendIntegration\Module->generate()
#20 system/modules/core/controllers/BackendMain.php(131): Contao\Backend->getBackendModule('metamodel_mm_pr...')
#21 contao/main.php(20): Contao\BackendMain->run()
#22 {main}

@discordier
Copy link
Member

So you are here trying to update a non existent value which should not happen at all.
Your fix will only silence the real problem.
How is it possible that you end up there with a tag list containing values which appear to be present in the database but in fact are not?

@MoniqueHahnefeld
Copy link
Author

yes the values in the database are not useable then anymore - that's fakt. but the real problem is that i was not able to give in new values, because the error broke up the parsing of the attribute. so i think it's a relevant fix.

I end up there because of customer wishes to change and I'm not sure, think the perception that the alias is nicer in the url as the id =) . it was a month ago...

@discordier
Copy link
Member

I meant how you end up in that code location with invalid values.
You mean the tags have been deleted?

@MoniqueHahnefeld
Copy link
Author

@discordier i don't understand you. maybe we can talk about at the next opportunity?

@zonky2
Copy link
Contributor

zonky2 commented Aug 26, 2016

Hi Monique, how can I make a setup to test and check your PR?

@discordier
Copy link
Member

I still have no clue how to reproduce the issue this fix is fixing or trying to fix...

@zonky2
Copy link
Contributor

zonky2 commented Jan 18, 2017

no response...

@zonky2 zonky2 closed this Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants