HTMLPurifier/DefinitionCache/Serializer not writable

Hello, I have been working for 3 days to solve this problem/var/www/xxxxxx/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php(103): An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directoryServer (192.168.x.6):
OS: centos 7
web: nginxServer DB (192.168.x.23):
DB : mariadb10this is error log
2022/01/18 14:35:07 [error] 4726#4726: *6571858 FastCGI sent in stderr: “PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297” while reading response header from upstream, client: 20.20.20.63, server: my.domain, request: “GET /login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”, host: “my.domain”
2022/01/18 14:35:47 [error] 4720#4720: *6571897 FastCGI sent in stderr: “PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297PHP message: PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable, please chmod to 777 in /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php on line 297” while reading response header from upstream, client: 20.20.20.63, server: my.domain, request: “POST /login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”, host: “my.domain”, referrer: “https://my.domain/login
I appreciate any advices

As the error message said, you should make the folder writable.

It is already set to 777this from the debug

#0 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(1767): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)
#1 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(1714): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)
#2 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(327): Doctrine\DBAL\Connection->convertException(Object(Doctrine\DBAL\Driver\PDO\Exception))
#3 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(1506): Doctrine\DBAL\Connection->connect()
#4 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(1013): Doctrine\DBAL\Connection->getWrappedConnection()
#5 /var/www/my.domain/vendor/doctrine/dbal/src/Connection.php(549): Doctrine\DBAL\Connection->executeQuery('SELECT COUNT(*)...', Array, Array)
...

That is another completely different error (PDO\Exception) which you did not post the complete details. What is the complete error message and the source code of the error line?

the source code of error is on serializer.php line 297:
trigger_error(
'Directory ’ . $dir . ’ not writeable, ’ .
'please chmod to ’ . decoct($chmod),
E-USER_WARNING
);the complete error is:
/var/www/editor-ehdw.kemendesa.go.id/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php(103): An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directoryExceptionConverter.php line 103 is
return new ConnectionException($exception, $query)

i had to use
chcon -t httpd_sys_rw_content_t /var/www/html/xxxxx -r
running it on httpd on centos 7

You may read Customize - HTML purifier to learn more information:

For performance reasons, HTML Purifier caches generated HTMLPurifier_Definition objects in serialized files stored (by default) in library/HTMLPurifier/DefinitionCache/Serializer.

Thank you for all suggestions,
I still did not get the right direction…

You posted 2 different error messages:dilistimor wrote:

PHP Warning: Directory /var/www/my.domain/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable

As explained, for performance reasons, HTML Purifier generates cache, so the folder should be writable.arbei wrote:

As the error message said, you should make the folder writable.

dilistimor wrote:

Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)

That is error when your PHP try to execute ‘SELECT COUNT(*)…’.arbei wrote:

…you did not post the complete details. What is the complete error message and the source code of the error line?

It seems that your PHP cannot connect to database. Make sure you have enabled the required driver for the database, see Composer. If you have uploaded your script to your server, make sure the connection info is correct on your server, you need to change the connection info in the config.development.php or config.production.php, depending on your Environment setting.

Thank youIn case of HTMLPurifier:

  1. The directory and file already set to 777
  2. Another possibility is to patch the HtmlPurifierFilter.php

In case of DB Connection, I use direct connection as it is allowed between server.
So I did not use tunnel.php. I will consider this issue toAnd also I use composer v 1.x, since composer 2 did not work right with phpmaker v2022

arbei wrote:

You may read > Customize - HTML purifier > to learn more information:

You may try “Turn off caching”.dilistimor wrote:

And also I use composer v 1.x, since composer 2 did not work right with phpmaker v2022

That is incorrect. Composer v2.2.3 (or newer) had fixed its bug and works fine with PHPMaker v2022, read: https://discourse.hkvstore.com/t/interface-psr-http-message-requestfactoryinterface-not-found/3419/1

Alright I update into v-2.x
Generate the code again and upload to server, hopefully eliminate some problems

Composer updated to v.2, after upload to production server, there is need to upgrade php
Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 7.4.0”.
On server php version is 7.3.33Now I’m afraid upgrading PHP will cause big issue at existing running application

dilistimor wrote:

Now I’m afraid upgrading PHP will cause big issue at existing running application

No, it won’t. There were only minor changes from PHP 7.3 to 7.4, see Migrating from PHP 7.3.x to PHP 7.4.x.If your hosting provider supports switching PHP versions (many providers do), you may always switch back. In fact, if PHP 8 is supported, you should use PHP 8. (Upgrade PHP on your PC to PHP 8 to match development and production environment also.)

Thank youI follow your instruction to adjust development envi with production envi
and also upgrade composer to v2it is running well nowThank you very much to all of you that have been give advices to this thread