Ibexa DXP Discussions

Community discussion forum for developers working with Ibexa DXP

Add attribut to ContentType that has many instances


I am facing a recurring problem with eZ. Modify a class (ContentType) that has many instances.

In my case I want to add an attribute to the article class (id = 2).

[1] I go to the BO and add my attribute.

[2] I click on “Apply” and I have the following message in green.

The Content type draft was successfully updated.

[3] I click OK and after a moment I have the following message in red!

Failed to load ‘http://edb.lxc/pjax/contenttype/update/2/eng-GB

In eZ4, after step 2 we could launch a script to apply the modify to all the exitents objects. (I do not know if this script is native …)

How do we do this in ezplatform?

Similar to http://share.ez.no/forums/ez-platform/cannot-update-and-publish-content-type
But doing the class change in a script would fix my pb …

Kaliop Migrations bundle may also be a solution …

Super easy :slight_smile:

namespace Smile\ToolsBundle\Command;

use eZ\Publish\API\Repository\Repository;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class PublishContentTypeDraftCommand extends ContainerAwareCommand
    /** Super admin ID */
    const CREATOR_ID = 14;

    protected function configure()
            ->setDescription("  php -d memory_limit=-1 app/console smile:tool:publish-content-type-draft article  ")
            ->addArgument('content_type_identifier', InputArgument::REQUIRED, 'Argument content_type_identifier')

    protected function execute(InputInterface $input, OutputInterface $output)

        $content_type_identifier = $input->getArgument('content_type_identifier');

        /** @var Repository $repository */
        $repository = $this->getContainer()->get('ezpublish.api.repository');
        $contentTypeService = $repository->getContentTypeService();
        $siteContentType = $contentTypeService->loadContentTypeByIdentifier($content_type_identifier);
        $contentTypeDraft = $contentTypeService->loadContentTypeDraft($siteContentType->id);


     * Se loger en tant que super admin.
     * @throws \Exception
    protected function logAsSuperAdmin()
        /** @var Repository $repository */
        $repository = $this->getContainer()->get('ezpublish.api.repository');
        $userID = self::CREATOR_ID;
        $user = $repository->getUserService()->loadUser($userID);
        if (!$user) {
            $msg = "Le user $userID n'existe pas.";
            throw new \Exception($msg);

subsidiary question: How to put syntax highlighting in discuss ?



Make a pull request!

With pleasure.
But how to do that?

Lets first ask @andrerom where could this be added, in which repo, etc

Let’s check with @lserwatka or @bdunogier on that, might be kernel, but from the looks of it there are a few more things to identify before we can add it:

  • should UI be adapted to tell you to publish via CLI on large content items?
  • is the script tested on large amount of items? (is there any chance of memory issues or timeout issues?)

Hi @andrerom,

I tested my script on a class with 4950 objects.
Obviously, with this volume it does not go in the BO.
I did my test with the BO in ez 1.13. Maybe it works better in ez 2.1.
In 1.13 the bo is in ajax and therefore the server errors are little hidden. (Which is a pity.) So I do not know if it’s a timeout or a memory problem.

1 Like

In the second point above I’m not taking about the BO (admin UI), I’m talking about your script, aka your command.

Any solution for the problem !!

Use kaliop Migration bundle. He’s gonna crash. But you can restart it until it passes…