Problem/Motivation
This sounds like some kind of permissions issue, but I've checked the write permissions for modules/contrib and it's wide open.
When I press the "Write All Files" button on the "Generate Code" tab, I get a series of errors announcing that there's a "Problem writing file *" for all possible files.
Yet when I try to write individual files using the buttons for writing them, I get no error.
In either case, there's no new module code written in modules/contrib and no new directory structure either.
Steps to reproduce
* Clean install of Drupal 9.0.7.
* Add module builder
| Comment | File | Size | Author |
|---|---|---|---|
| Capture.PNG | 120.26 KB | bogdog400 |
Comments
Comment #2
joachim commentedCould you try debugging in the writeSingleFile() method please?
Is file_put_contents() getting the right path to write? Can you check that PHP thinks the path is writeable?
Comment #3
bogdog400 commentedWhen I press the "write file" button for each individual file, I get no error. But when I look in directory, there's no file. Nothing. Not even a directory for the module.
Comment #4
joachim commentedCould you do some debugging in the code please? I can't fix this problem without more detail.
Comment #5
bogdog400 commentedI'm happy to try some basic things, but this is running on a virtual instance. If you want me to install any logging code, I'm happy to do so but I generally don't know much about connecting a debugger to a running virtual instance across the web. IF you can point me to a tutorial, I wouldn't mind trying because it sounds like a useful skill to have.
Comment #6
joachim commented> running virtual instance across the web
Ok that's probably your problem -- the server will have checks to prevent files being written by running code!
Module Builder should only be run locally.
Comment #7
joachim commented> Yet when I try to write individual files using the buttons for writing them, I get no error.
Although the lack of an error message there is a bug. I've just fixed that, will be in the next release.
Comment #8
bogdog400 commentedWhen I say running on a server, it's running "locally" on the server. I log in and trigger it over the web. It's not like I expect the module files to be written on my desktop. No. I expect them to be written on the machine where it's running.
When you add more error messages, could you add more explanation, perhaps an error code from the OS?
Thx.
Comment #9
joachim commented> When I say running on a server, it's running "locally" on the server. I log in and trigger it over the web
If the site is running on a remote machine and you're logging in over the web, then you shouldn't put Module Builder on it.
When I say debugging, I mean put in some dump() or dpm() statements in the code to see what's going on.
Comment #10
bogdog400 commentedWhy shouldn't I use Module Builder? I use the remote machine just as I would a desk top. I have root access. Can you explain?
Comment #11
joachim commentedModule Builder writes files to the site's codebase. You can overwrite existing modules with it, and therefore totally break the site.
If a site is accessible over the web, then there is potential for an attacker to gain access, get to the Module Builder UI, and break the site.
For that reason, Module Builder should only be used locally.
To debug your problem, you're going to need to edit the Module Builder code files to put in debug statements. I assume you can do this, because otherwise, what's the point in writing the generated code files to that server?
Comment #12
bogdog400 commentedYes, I can write and edit the module code. If you want me to put in debug statements, I'm happy to do so.
THx.
Comment #13
joachim commentedTry debugging in writeSingleFile() -- get Devel module so you can use dpm() and output the result of is_writable() for the folder and the file.