How to install Acquia's Custom Objects plugin?

Hi,

Really excited about the news today that Acquia has released custom objects plugin.

I’m not quite sure how to install it.

I don’t use Composer yet, so I’ve downloaded a .zip file of the staging branch from GitHub. I extract the zip in my plugins directory and rename the folder to “CustomObjectsBundle” (as this is the name in composer.json), and clear the cache.

When I try to access Mautic, I get an internal server error and this message in my logs:

*69710 FastCGI sent in stderr: "PHP message: Symfony\Component\ErrorHandler\Error\ClassNotFoundError: Attempted to load class "CustomObjectPermissions" from namespace "MauticPlugin\CustomObjectsBundle\Security\Permissions".
Did you forget a "use" statement for another namespace? - in file /usr/share/nginx/example.com/var/cache/prod/ContainerHk05SG4/appAppKernelProdContainer.php - at line 6249" while reading response header from upstream, client: 1.2.3.4.5, server: example.com, request: "GET /s/plugins HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "example.com"

This error can occur when the filenames don’t exactly match the PHP classnames, but there is definitely a CustomObjectPermissions.php file in plugins/CustomObjectsBundle/Security/Permissions/, so I don’t think it’s that.

Anybody had a similar issue? Any ideas?

1 Like

Are you on Mautic 4.3.1? That is the minimum required version.

Yes, Mautic 4.3.1 and PHP 7.4.3.

Try to clear cache with rm -rf var/cache/*

No luck, I’m afraid :frowning:

It should be a cache issue based on the error message:

Please double-check.

If I clear the cache, the error re-occurs but with a slightly different filepath.

It might have been a permissions error on the plugins/CustomObjectsBundle/Security/Permissions/CustomObjectPermissions.php file. I’ve chmodded the file to 755, and it the log message has stopped.

I’m still getting Internal Server Errors when I try to access Mautic, but this time with this error in Mautic’s log:

[2022-05-24 16:00:32] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException: "An exception occurred while executing 'SELECT c0_.is_published AS is_published_0, c0_.date_added AS date_added_1, c0_.created_by AS created_by_2, c0_.created_by_user AS created_by_user_3, c0_.date_modified AS date_modified_4, c0_.modified_by AS modified_by_5, c0_.modified_by_user AS modified_by_user_6, c0_.checked_out AS checked_out_7, c0_.checked_out_by AS checked_out_by_8, c0_.checked_out_by_user AS checked_out_by_user_9, c0_.id AS id_10, c0_.alias AS alias_11, c0_.name_singular AS name_singular_12, c0_.name_plural AS name_plural_13, c0_.description AS description_14, c0_.lang AS lang_15, c0_.type AS type_16, c0_.category_id AS category_id_17, c0_.relationship_object AS relationship_object_18, c0_.master_object AS master_object_19 FROM custom_object c0_ LEFT JOIN categories c1_ ON c0_.category_id = c1_.id WHERE c0_.is_published = ?' with params [1]:  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.custom_object' doesn't exist" at /usr/share/nginx/example.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 61 {"exception":"[object] (Doctrine\\DBAL\\Exception\\TableNotFoundException(code: 0): An exception occurred while executing 'SELECT c0_.is_published AS is_published_0, c0_.date_added AS date_added_1, c0_.created_by AS created_by_2, c0_.created_by_user AS created_by_user_3, c0_.date_modified AS date_modified_4, c0_.modified_by AS modified_by_5, c0_.modified_by_user AS modified_by_user_6, c0_.checked_out AS checked_out_7, c0_.checked_out_by AS checked_out_by_8, c0_.checked_out_by_user AS checked_out_by_user_9, c0_.id AS id_10, c0_.alias AS alias_11, c0_.name_singular AS name_singular_12, c0_.name_plural AS name_plural_13, c0_.description AS description_14, c0_.lang AS lang_15, c0_.type AS type_16, c0_.category_id AS category_id_17, c0_.relationship_object AS relationship_object_18, c0_.master_object AS master_object_19 FROM custom_object c0_ LEFT JOIN categories c1_ ON c0_.category_id = c1_.id WHERE c0_.is_published = ?' with params [1]:\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.custom_object' doesn't exist at /usr/share/nginx/example/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:61, Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.custom_object' doesn't exist at /usr/share/nginx/example.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.custom_object' doesn't exist at /usr/share/nginx/example.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)"} {"hostname":"example","pid":12345}

So I need to apply some database migrations before the plugin will function. How do I go about doing this?
php bin/console doctrine:migration:status returns no new migrations.

EDIT: I’ve just tried running php bin/console mautic:plugins:install and get an error message about the leads table not existing (it does exist!). Seems related to GitHub issue 11163.

Are you sure you are on Mautic 4.3.1? The bug with the lead table was fixed in 4.3.0. Instances with DB prefix set failed after #11059 by escopecz · Pull Request #11128 · mautic/mautic · GitHub

And yes, the plugin database schema will be configured when you run bin/console mautic:plugins:install

Yeah, I’m definitely running 4.3.1. I upgraded through the command line with no issues. php bin/console mautic:update:find shows I’m currently on the latest version.

I don’t use any db prefix - it’s set to null - if that makes a difference?

Thanks for your help with this.

EDIT: I’ve added prefixes to my DB, and the error still happens, so it’s not that!
I’ll try a fresh mautic install on a different domain… See if it’s something peculiar to my current mautic instance.

I got the same message when installing the custom objects plugin…

I have tried installing and it is breaking my installation. I am going to run a totally clean installation but it would be great if there were some more detailed installation instructions for this plugin (not using composer).

For example what should the plugin directory be called ?
Do we need to run Mautic:plugins:install or can this be done from the UI ?

2 Likes

Yes, I completely agree! Feels like I’m stumbling in the dark trying to figure the installation out…
(I don’t mean this as a criticism, I’m sure a lot of people have worked hard on it, and Mautic is an excellent free product - I’m just quite confused!)

Just to confirm, I’ve run a fresh install of 4.3.1 with an emtpy database.

I get the same internal server error, with the same error message in my Mautic log about the custom_object table not being found.

When I try to run php bin/console mautic:plugins:install, I get the same error as before:

There is no table with name 'mautic.leads' in the schema.

I’m not able to replicate. It passes fine for me on 4.3.1:

bin/console mautic:plugins:install
0 new plugins were installed and 0 updated.

So the question is what is different on your instance. Try if this would give us some more details about the error:

bin/console mautic:plugins:install -vvv

Here’s the output of that command:

In SchemaException.php line 34:

  [Doctrine\DBAL\Schema\SchemaException (10)]
  There is no table with name 'mautic.leads' in the schema.


Exception trace:
  at /usr/share/nginx/example.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php:34
 Doctrine\DBAL\Schema\SchemaException::tableDoesNotExist() at /usr/share/nginx/example.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php:178
 Doctrine\DBAL\Schema\Schema->getTable() at /usr/share/nginx/example.com/app/bundles/InstallBundle/EventListener/DoctrineEventSubscriber.php:27
 Mautic\InstallBundle\EventListener\DoctrineEventSubscriber->postGenerateSchema() at /usr/share/nginx/example.com/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php:64
 Symfony\Bridge\Doctrine\ContainerAwareEventManager->dispatchEvent() at /usr/share/nginx/example.com/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php:409
 Doctrine\ORM\Tools\SchemaTool->getSchemaFromMetadata() at /usr/share/nginx/example.com/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php:116
 Doctrine\ORM\Tools\SchemaTool->getCreateSchemaSql() at /usr/share/nginx/example.com/app/bundles/PluginBundle/Bundle/PluginBundleBase.php:47
 Mautic\PluginBundle\Bundle\PluginBundleBase::installPluginSchema() at /usr/share/nginx/example.com/app/bundles/PluginBundle/Bundle/PluginBundleBase.php:27
 Mautic\PluginBundle\Bundle\PluginBundleBase::onPluginInstall() at /usr/share/nginx/example.com/app/bundles/PluginBundle/Helper/ReloadHelper.php:133
 Mautic\PluginBundle\Helper\ReloadHelper->installPlugins() at /usr/share/nginx/example.com/app/bundles/PluginBundle/Facade/ReloadFacade.php:40
 Mautic\PluginBundle\Facade\ReloadFacade->reloadPlugins() at /usr/share/nginx/example.com/app/bundles/PluginBundle/Command/ReloadCommand.php:35
 Mautic\PluginBundle\Command\ReloadCommand->execute() at /usr/share/nginx/example.com/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /usr/share/nginx/example.com/vendor/symfony/console/Application.php:1027
 Symfony\Component\Console\Application->doRunCommand() at /usr/share/nginx/example.com/vendor/symfony/framework-bundle/Console/Application.php:97
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /usr/share/nginx/example.com/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /usr/share/nginx/example.com/vendor/symfony/framework-bundle/Console/Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /usr/share/nginx/example.com/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /usr/share/nginx/example.com/bin/console:42

mautic:plugins:reload [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

I have gone ahead and done my first successful installation of Mautic 4.3.1 with composer!!
I installed on Ubuntu 22.04 LTS with php7.4 and LEMP.

I went and enabled composer update in config and tried to install the module from the Marketplace and got the following error:

This is what I am seeing in the system log

[2022-05-27 12:25:08] mautic.ERROR: PHP Error: Maximum execution time of 30 seconds exceeded - in file /var/www/ams/app/bundles/CoreBundle/Loader/TranslationLoader.php - at line 106 [] {"hostname":"ams","pid":2648}
[2022-05-27 12:25:08] mautic.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Error: Maximum execution time of 30 seconds exceeded - in file /var/www/ams/app/bundles/CoreBundle/Loader/TranslationLoader.php - at line 106 [] {"hostname":"ams","pid":2648}

Maximum execution time usually means your server resources are not sufficient:

for non compser installs, looks like we are waiting for…

1 Like

Well spotted!

Thanks - i keep following this one as we’re hoping to play with this to see how it works…