Category: "Symfony"

Rocky Linux 9 - wkhtmltopdf

I kept getting a divide by zero error (Signal 8) with wkhtmltopdf under Rocky Linux

RPM in use: wkhtmltox-0.12.6.1-2.almalinux9.x86_64.rpm (credit to: https://forums.rockylinux.org/t/need-to-install-wkhtmltopdf-for-rocky-linux-9-how/6758/2)

This was running under Ibexa, with Symfony.

I stripped it down to test with the output of the application on the command line and isolated the issue to a <link> tag for Bootstrap 4.3 by commenting out tags until I found which one was causing the issue.

I don't care what the issue was - upgrading Bootstrap to 4.6 worked

I hope this helps someone - it was frustrating.

 

mod_proxy_ajp declining URL

Many hours of searching and suffering were spent trying to resolve this ...

Apache-Error: [file "mod_proxy_ajp.c"] [line 743] [level 7] AH00894: declining URL fcgi://localhost/var/www/html/site/public/index.php

This is a Symfony application (ibexa DXP, formerly eZ Platform, previously eZ Publish), CentOS 8 server, with PHP 7.4, mod_security, selinux enabled, etc.

The error was thrown on the graphql requests to support the sub-items display of the admin interface.

The root cause of the issue was an application error.

The message from Symfony

[2022-01-05T18:34:58.709826+00:00] request.CRITICAL: Uncaught PHP Exception Overblog\GraphQLBundle\Resolver\UnresolvableException: "Could not found type with alias "RepositoryLanguage". Do you forget to define it?" at /var/www/html/site/vendor/overblog/graphql-bundle/src/Resolver/TypeResolver.php line 72 {"exception":"[object] (Overblog\\GraphQLBundle\\Resolver\\UnresolvableException(code: 0): Could not found type with alias \"RepositoryLanguage\". Do you forget to define it? at /var/www/html/site/vendor/overblog/graphql-bundle/src/Resolver/TypeResolver.php:72)"} []

This also took me a long time to unravel - about an hour ... because I haven't worked with eZ in a while

Solution was to copy all these files https://github.com/bgamrat/improved-journey/tree/main/config/graphql/types/ezplatform into the config.

Next, it was time to make this blog post with the goal of helping you!

I changed the username for security, to a word I rarely use. So of course I forgot it. As well as the password. Tried to email a password reset, but that failed too ... selinux, remember?

setsebool -P httpd_can_sendmail 1

I also tried to reset the password at the database level, but that looked like more effort.

So - it was a grand adventure, the installation works and I can go do other things.

Returning custom headers with FOSRestBundle

The Content-Range header supports a (dgrid) OnDemandGrid

Returning custom headers with FOSRestBundle


use FOS\RestBundle\View\View as FOSRestView;
...
$view = FOSRestView::create();
$view->setData($data);
$view->setHeader( 'Content-Range', 'items '.$offset.'-'.($offset+$limit).'/'.$count);
$handler = $this->get('fos_rest.view_handler');
return $handler->handle($view);

Ref: https://symfony.com/doc/1.5/bundles/FOSRestBundle/2-the-view-layer.html

Symfony 4

Symfony 4 - Multiple DataFixtures files

I recently upgraded a Symfony 3.3 application to Symfony 4

Part of the upgrade was loading the DataFixtures.

Symfony 4 recommends you put all your DataFixtures in a single file. I'll get around to that later. However, due to the way I organized the file system for the project, the Doctrine Fixtures Loader could not find the demo data.

Symfony 4 - Multiple DataFixtures files

To resolve the issue, I created a services_dev.yaml file with the following:

services:
    App\DataFixtures\Demo\:
        resource: '../src/DataFixtures/Demo/*'
        tags: [ doctrine.fixture.orm ]

Once I added this file to the development server, the data loaded fine.

Ref: https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html#multiple-files

Upgrading from Symfony 3 to 4 - JSON Database Content

My latest adventure has been to upgrade a web application from Symfony 3.3 to 4. All the pages load and I am starting to test execution.

This error came up and I scoured the code for instances of AppBundle

Upgrading from Symfony 3 to 4 - JSON Database Content

Then I checked the database.

One of the attributes is custom_attributes, which is a JSON column. Sample content:

[{"#type":"AppBundle\\Entity\\CustomAttribute","key":"expiration","value":"2018-02-26","valueValidExpiration":true,"valueValidChannels":true},{"#type":"AppBundle\\Entity\
\CustomAttribute","key":"channels","value":6,"valueValidExpiration":true,"valueValidChannels":true}]

I am using https://github.com/dunglas/doctrine-json-odm to provide JSON data within entities.

To change AppBundle to App, I used:

dev=# UPDATE asset SET custom_attributes= REPLACE(custom_attributes::TEXT,'AppBundle','App')::json;
UPDATE 25
dev=# UPDATE model SET custom_attributes= REPLACE(custom_attributes::TEXT,'AppBundle','App')::json;
UPDATE 9

1 3