[Bug]: Classes rebuild with --create-classes does not create classes if they are not present in the folder yet.
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.
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.
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 It deletes ALL classes? Even if they still exist?
@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 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 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.
If it helps I can try to reproduce it using a fresh installation.
@paulhaem yes, a reproducible case (ideally Docker setup) would help a lot! Thanks in advance
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:
why not use pimcore:build:classes during container build?
I say it like this: Yes would work, probably the better way, but not refactored yet ;)
why not use
pimcore:build:classesduring 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 😉).
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.
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.
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 ?