pimcore icon indicating copy to clipboard operation
pimcore copied to clipboard

[Bug]: Classes rebuild with --create-classes does not create classes if they are not present in the folder yet.

Open ascheider opened this issue 1 year ago • 15 comments

Pimcore version

11.4.1

Steps to reproduce

Spotted minor issue which this commit: https://github.com/pimcore/pimcore/commit/b4591f0936f2e448cdebac5e31dc40c2ab29392a caused. We version data definition of the classes in git, on deployment we call bin/console pimcore:deployment:classes-rebuild --create-classes which generates the classes in var/classes/DataObject folder. With this optimization the classes are not created anymore if they are not present in the folder. I can create them only if i run it with force flag. In my opinion rebuild with --create-classes should consider creating them if they are not present yet not depending on modification date. Currently i overcome the issue with pimcore:deployment:classes-rebuild --create-classes -f

How to reproduce. 1.) Create class via admin and save it 2.) Delete folder var/classes/DataObject 3.) Run bin/console pimcore:deployment:classes-rebuild --create-classes 4.) Classes are not created in var/classes/DataObject directory, only if force flag is executed

Actual Behavior

Missing classes in var/classes/DataObject after rebuild

Expected Behavior

Classes should present in var/classes/DataObject after rebuild if they are not generated.

ascheider avatar Nov 11 '24 09:11 ascheider

Thanks a lot for reporting the issue. We did not consider the issue as "Pimcore:Priority", "Pimcore:ToDo" or "Pimcore:Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

github-actions[bot] avatar Dec 02 '24 07:12 github-actions[bot]

Using Pimcore Version 11.4.4.

We are experiencing the same issue since moving from 11.1 to 11.4. During the deployment workflow we are using the create / destroy flag to keep classes clean. This now leads to deletion of all the classes without creating any classes. Classes are only created when using the force flag.

Are there any news regarding this issue?

paulhaem avatar Jan 15 '25 07:01 paulhaem

@paulhaem It deletes ALL classes? Even if they still exist?

dpfaffenbauer avatar Jan 15 '25 07:01 dpfaffenbauer

@dpfaffenbauer Hey Dominik,

it does not create them in DataObject folder if they do not present. We do not version DataObject folder in git, only the definition. On deployment we run the command, since the change the classes are not created on file system, only if using force. We added force flag on deployment, but its bit annoying.

ascheider avatar Jan 15 '25 08:01 ascheider

@ascheider But nothing gets deleted that should not be deleted right? That would be a major red flag ;)

Re creation: Pimcore changed that only changed class-definitions are updated, the force flag updates everything (like it used to be before). I guess its a Bug in there with missing classes.

dpfaffenbauer avatar Jan 15 '25 08:01 dpfaffenbauer

@dpfaffenbauer No, not all of them. It deleted most of the classes: the var/classes/DataObjects folder contained no classes itself but a few classes remained that were grouped into folders, but not all of them. I was not able to see any pattern for when a class was not deleted.

paulhaem avatar Jan 15 '25 08:01 paulhaem

If it helps I can try to reproduce it using a fresh installation.

paulhaem avatar Jan 15 '25 08:01 paulhaem

@paulhaem yes, a reproducible case (ideally Docker setup) would help a lot! Thanks in advance

brusch avatar Jan 15 '25 09:01 brusch

If it helps: It is reproducable, when you use a Docker Compose config where the DataObject folder is a volatile volume (lives in ram memory).

We use this construct in combination with a kind of "init script", that (also) runs classes-rebuild on container startup.

Or in other words: We regenerate all classes on container startup.

services:
  pimcore:
    ...
    volumes:
      - pimcore-public-var:/var/www/html/public/var/:rw
      - pimcore-var-classes-dataobject:/var/www/html/var/classes/DataObject/:rw
      - pimcore-var-config:/var/www/html/var/config/:rw
      - pimcore-var-log:/var/www/html/var/log/:rw
      - pimcore-var-recyclebin:/var/www/html/var/recyclebin/:rw
      - pimcore-var-versions:/var/www/html/var/versions/:rw

volumes:
  pimcore-public-var:
  pimcore-var-classes-dataobject:
    labels:
      volatile: "true"
  pimcore-var-config:
  pimcore-var-log:
  pimcore-var-recyclebin:
  pimcore-var-versions:

lukadschaak avatar Jan 20 '25 18:01 lukadschaak

why not use pimcore:build:classes during container build?

dpfaffenbauer avatar Jan 20 '25 19:01 dpfaffenbauer

I say it like this: Yes would work, probably the better way, but not refactored yet ;)

lukadschaak avatar Jan 20 '25 20:01 lukadschaak

why not use pimcore:build:classes during container build?

I think it's currently the way it is because of DX. If you generate the classes during container build, you have to rebuild the container every time you change the classes, right?

With the current solution, the next developer just has to (re)start their container after pulling a branch with changed definitions, and the classes (including the database) are automatically updated.

But for deployments it would certainly be better to “bake them in” via pimcore:build:classes during container build, yes (unless, of course, Pimcore breaks this command again 😉).

jdreesen avatar Jan 21 '25 08:01 jdreesen

For production, you have to build anyway, since the definitions are part of the container.

For Dev, we don't run entrypoint scripts at all, the developer manually runs the necessary commands in the CLI.

dpfaffenbauer avatar Jan 21 '25 08:01 dpfaffenbauer

For Dev, we don't run entrypoint scripts at all, the developer manually runs the necessary commands in the CLI.

We have made the experience that this is difficult for some developers (especially frontend developers). That's why we created the entrypoint scripts.

jdreesen avatar Jan 21 '25 09:01 jdreesen

Since I have just encountered the same issue... Should I run pimcore:build:classes on each deployment on production? Or classes-rebuild is a better option? @dpfaffenbauer ?

alexdrupal avatar Oct 30 '25 11:10 alexdrupal