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

HTMLPurifier should have its cache directory replaced #264

Closed
mattgrayisok opened this issue Dec 15, 2020 · 13 comments
Closed

HTMLPurifier should have its cache directory replaced #264

mattgrayisok opened this issue Dec 15, 2020 · 13 comments

Comments

@mattgrayisok
Copy link

mattgrayisok commented Dec 15, 2020

Description
HTMLPurifier tries to use the vendor folder as a cache directory. This is bad for several reasons, some of which are discussed here: ezyang/htmlpurifier#71 . My specific issue is that Servd has non-writable vendor folders (security 💪) so HTMLPurifier gets all upset with the following error:

PHP User Warning – yii\base\ErrorException
Directory /var/www/html/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777

please chmod to 777

🤣

As a result they added a method to overwrite the cache dir.

Yii2 uses HTMLPurifier under the hood and they hit the same issue and ensured it was using a custom cache dir during its setup:

https://github.com/yiisoft/yii2/blob/da447fd1bb9778b8b76994f3e3e14f9748c67625/framework/helpers/BaseHtmlPurifier.php#L47

I'd recommend applying a similar config overwrite to the instantiation of HTMLPurifier in formie too if poss, maybe using the craft cache folder instead:

$config = HTMLPurifier_Config::createDefault();

Steps to reproduce

  1. Use formie on Servd or any other platform with a non writable vendor folder

Cheers

@engram-design
Copy link
Member

Didn't even realise it did this! Should be fixed in 1.3.4

@DynamiteGoesBoom
Copy link

@engram-design Thanks for hopping on this so quick, we'll test it on our end and let you know if there are any issues 👍

@DynamiteGoesBoom
Copy link

DynamiteGoesBoom commented Dec 16, 2020

@engram-design It looks like there's a new issue now:

Screen Shot 2020-12-15 at 5 29 48 PM

We have a Global Formie Form Select field, that allows us to assign a formie form into the Footer of our project. When I save that field that's when the error above appears.

The weird thing is that we're not using a ST field there, it's a standalone Formie FieldType.

@engram-design
Copy link
Member

@DynamiteGoesBoom Strange. Are you able to send through the entire stack trace, or better, the content of web.log so I can see the trace of where this is coming from?

@DynamiteGoesBoom
Copy link

@engram-design ask and you shall receive:

yii_base_ErrorException

yii\base\ErrorException: Undefined property: verbb\supertable\elements\db\SuperTableBlockQuery::$errorImage in /var/www/project/cms/vendor/yiisoft/yii2/base/ArrayableTrait.php:126
Stack trace:
#0 /var/www/project/cms/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(8, 'Undefined prope...', '/var/www/projec...', 126)
#1 /var/www/project/cms/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\web\ErrorHandler->handleError(8, 'Undefined prope...', '/var/www/projec...', 126, Array)
#2 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1638): craft\elements\db\ElementQuery->toArray(Array, Array, false)
#3 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1591): craft\elements\db\ElementQuery->getCriteria()
#4 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1502): craft\elements\db\ElementQuery->getCachedResult()
#5 /var/www/project/cms/vendor/verbb/super-table/src/elements/db/SuperTableBlockQuery.php(110): craft\elements\db\ElementQuery->one()
#6 /var/www/project/cms/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): verbb\supertable\elements\db\SuperTableBlockQuery->__get('errorImage')
#7 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1638): craft\elements\db\ElementQuery->toArray(Array, Array, false)
#8 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1611): craft\elements\db\ElementQuery->getCriteria()
#9 /var/www/project/cms/vendor/verbb/super-table/src/fields/SuperTableField.php(541): craft\elements\db\ElementQuery->setCachedResult(Array)
#10 /var/www/project/cms/vendor/craftcms/cms/src/base/Element.php(3345): verbb\supertable\fields\SuperTableField->normalizeValue(Array, Object(craft\elements\GlobalSet))
#11 /var/www/project/cms/vendor/craftcms/cms/src/base/Element.php(2788): craft\base\Element->normalizeFieldValue('topNavigation')
#12 /var/www/project/cms/vendor/craftcms/cms/src/controllers/GlobalsController.php(249): craft\base\Element->setFieldValuesFromRequest('fields')
#13 [internal function]: craft\controllers\GlobalsController->actionSaveContent()
#14 /var/www/project/cms/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /var/www/project/cms/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#16 /var/www/project/cms/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('save-content', Array)
#17 /var/www/project/cms/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-content', Array)
#18 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('globals/save-co...', Array)
#19 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('globals/save-co...', Array)
#20 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#21 /var/www/project/cms/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /var/www/project/cms/web/index.php(21): yii\base\Application->run()
#23 {main}```

@engram-design
Copy link
Member

engram-design commented Dec 16, 2020

@DynamiteGoesBoom Can you confirm your Craft version as well?

@DynamiteGoesBoom
Copy link

@engram-design Sure thing:

Screen Shot 2020-12-15 at 5 39 32 PM

@engram-design
Copy link
Member

Looks like it's this issue - verbb/super-table#397 - unrelated to Formie and to do with Craft 3.5.17

@DynamiteGoesBoom
Copy link

@engram-design Hmm could be, but weird that we're not using a ST for that field and weird that another plugin would cause this. Gotta love web development #devLyfe :)

@engram-design
Copy link
Member

@DynamiteGoesBoom Does the global set contain a Super Table field though?

@DynamiteGoesBoom
Copy link

@engram-design Ahh yes it does. We have a Site Wide global with 2 tabs, and a ST on both tabs.

@engram-design
Copy link
Member

@DynamiteGoesBoom Should be fixed in Super Table 2.6.5

@DynamiteGoesBoom
Copy link

@engram-design Thanks again and looks like we're all squared away!

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

3 participants