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

oops, htmlspecialchars() expects parameter 1 to be string, array given (View.php:116) when modifying notification apply rule #1912

Closed
tlo8640 opened this issue Jul 18, 2019 · 2 comments

Comments

@tlo8640
Copy link

tlo8640 commented Jul 18, 2019

Expected Behavior

We created some notification apply rules and some of them are not editable anymore.
the rules should be editable in every case.

Current Behavior

When I click on one apply rule I get the following error message:

`
htmlspecialchars() expects parameter 1 to be string, array given (View.php:116)

#0 [internal function]: Icinga\Application\ApplicationBootstrap->Icinga\Application{closure}(2, 'htmlspecialchar...', '/usr/share/php/...', 116, Array)
#1 /usr/share/php/Icinga/Web/View.php(116): htmlspecialchars(Array, 58, 'UTF-8', true)
#2 /usr/share/icingaweb2/library/vendor/Zend/View/Helper/FormText.php(70): Icinga\Web\View->escape(Array)
#3 /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php(345): Zend_View_Helper_FormText->formText('assign_filter[i...', Array, Array)
#4 /usr/share/php/Icinga/Web/View.php(278): Zend_View_Abstract->__call('formText', Array)
#5 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(239): Icinga\Web\View->__call('formText', Array)
#6 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(216): Zend_View_Helper_FormDataFilter->selectGroup('host', Object(Icinga\Data\Filter\FilterMatch))
#7 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(164): Zend_View_Helper_FormDataFilter->element(Object(Icinga\Data\Filter\FilterMatch))
#8 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(178): Zend_View_Helper_FormDataFilter->filterExpressionHtml(Object(Icinga\Data\Filter\FilterMatch))
#9 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(83): Zend_View_Helper_FormDataFilter->renderFilterExpression(Object(Icinga\Data\Filter\FilterMatch))
#10 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(108): Zend_View_Helper_FormDataFilter->renderFilter(Object(Icinga\Data\Filter\FilterMatch))
#11 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(81): Zend_View_Helper_FormDataFilter->renderFilterChain(Object(Icinga\Data\Filter\FilterNot))
#12 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(108): Zend_View_Helper_FormDataFilter->renderFilter(Object(Icinga\Data\Filter\FilterNot))
#13 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(81): Zend_View_Helper_FormDataFilter->renderFilterChain(Object(Icinga\Data\Filter\FilterAnd))
#14 /usr/share/icingaweb2/modules/director/application/views/helpers/FormDataFilter.php(69): Zend_View_Helper_FormDataFilter->renderFilter(Object(Icinga\Data\Filter\FilterAnd))
#15 /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php(345): Zend_View_Helper_FormDataFilter->formDataFilter('assign_filter', Object(Icinga\Data\Filter\FilterAnd), Array, NULL)
#16 /usr/share/php/Icinga/Web/View.php(278): Zend_View_Abstract->__call('formDataFilter', Array)
#17 /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/ViewHelper.php(254): Icinga\Web\View->__call('formDataFilter', Array)
#18 /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php(2048): Zend_Form_Decorator_ViewHelper->render('')
#19 /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/FormElements.php(115): Zend_Form_Element->render()
#20 /usr/share/icingaweb2/library/vendor/Zend/Form/DisplayGroup.php(914): Zend_Form_Decorator_FormElements->render('')
#21 /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/FormElements.php(115): Zend_Form_DisplayGroup->render()
#22 /usr/share/icingaweb2/library/vendor/Zend/Form.php(2974): Zend_Form_Decorator_FormElements->render('')
#23 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/HtmlDocument.php(250): Zend_Form->render()
#24 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/BaseHtmlElement.php(175): dipl\Html\HtmlDocument->renderUnwrapped()
#25 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/BaseHtmlElement.php(198): dipl\Html\BaseHtmlElement->renderContent()
#26 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/HtmlDocument.php(193): dipl\Html\BaseHtmlElement->renderUnwrapped()
#27 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/HtmlDocument.php(262): dipl\Html\HtmlDocument->render()
#28 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Zf1/SimpleViewRenderer.php(65): dipl\Html\HtmlDocument->__toString()
#29 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Zf1/SimpleViewRenderer.php(104): dipl\Zf1\SimpleViewRenderer->render()
#30 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/HelperBroker.php(272): dipl\Zf1\SimpleViewRenderer->postDispatch()
#31 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(518): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#32 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch('editAction')
#33 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#34 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#35 /usr/share/php/Icinga/Application/webrouter.php(104): Icinga\Application\Web->dispatch()
#36 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...')
#37 {main}
`

apply Notification "alarm_service_host_notify_24x7" to Host {
    import "alarm_host_notify_template"
    assign where host.vars.notification_alarm_contact_name == "alarm_notify_service" && host.vars.notification_alarm_host_selector == "yes" && !(host.groups in [ "new_staged" ])
    users = [ "alarm_notify_service" ]
}

Previews of these rules are working. It seems, that only the edit view throws this error.

Possible Solution

Unfortunately, I have no idea
I found a bug with the same error message (#1200) but in the notification rule are no custom field and the fields, used in the apply statement are arrays, but the target data type is string in these fields.
I also tried to create the php file "Text.php" as described in the fix but it didn't helped.

Steps to Reproduce (for bugs)

Didn't tried to create additional rules

Your Environment

  • Director version (System - About): 1.6.2
  • Icinga Web 2 version and modules (System - About): 2.6.3
  • Icinga 2 version (icinga2 --version):
  • Operating System and version: RHEL 7, 64 Bit
  • Webserver, PHP versions: 7.1
@tlo8640
Copy link
Author

tlo8640 commented Jul 19, 2019

ok, it seems, I found the problem on my side in the config and thanks to icingacli I could fix it as far as I can see.
Short explanation (hopefully clear):
in the assign rule for the notification we checked if the host is in the hostgroup "new_staged" and if yes, the notification will no applied. some (a lot other stuff is also checked, but there seems to be no problem)
As far as I remember this worked when I configured it. Somehow (perhaps since the last director Update) i couldn't be shown anymore in Director:
this is the wrong part:

!(host.groups in [ "new_staged" ]) 

it should be:

!("new_staged" in host.groups) 

After fixing this with icingacli, the director could show these objects again, what makes me very happy

At least I don't know how this happened.

and it seemed, that director rendered the (old and wrong) notification object correctly, because the notifications were assigned correctly to the host and service objects.

@Thomas-Gelf
Copy link
Contributor

Thanks for letting us know!

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

No branches or pull requests

2 participants