New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include database.php only if it exists #543
Conversation
Adds an file check for the database configuration and includes the file only if it exists. The datasource configuration might not be always available e.g. for application bootstrapping via an webfront. The patch inits an empty configuration if no database.php file is present.
Here a more detailed description of my pull request: My web gallery phtagr.org has an installation setup procedure to create the database configuration file via the web interface. The user inserts the database config details in a form and than the file is written by the application. However, the Form helper checks the model data which initializes the ConnectionManager. Since the database.php file does not exists yet CakePHP gives a warning on opening an invalid file. I propose to add the given check to ConnectionManager. But if there is another way to bypass this issue, I'm happy, too. |
I'm onboard with this change. Any objections? It doesn't change the 2.1 API, and helps apps with installers out. |
You could turn off debugging in your view to workaround this issue, eg: croogo/croogo@4b71a05 |
I object, increasing IO in every request just for ease the task of writing installers is IMO not a good idea. Installers could do the checking before and not use models in the form helper. |
One can do $this->Form->create(false); and tell the helper not a use a model isn't it? |
I agree with ADmad and lorenzo. One other thing to take into consideration: calling ConnectionManager::create() to test provided credentials would always error out if the file isnt present. |
Closing then, seems there isn't a ton of interest in merging this in and several alternatives have been provided. |
thank you very much for this great response. @ADmad: I've tried $this->Form->create(false); and $this->Form->create(null); but did not help. @rchavik: Thanks for this great idea to suppressing debug warnings with Configure::write('debug', 0) at this point! That will do the job! So closing is fine. Best regards, Xemle PS: @lorenzo: I agree to avoid increasing IO. Another proposal is suppressing the warning by prefixing '@' of include_once statement, if this issue is still hot.
Warnings:
Stacktrace:
|
@xemle Have you tried using field name like 'login' instead of 'db.login'? |
Yes, makes no changes. Is there a way to suppress the field validation check in form helper which does not introspect the model? Might be useful for inputs which do not belong to a model. |
Use something that is not a model such as $this->Form->create(false); $this->Form->input('my_field'); That will be tied to no model |
That's what i had suggested, perhaps I was not clear enough. |
OK, my fault. I did not replace all form field prefixes. It works without the dot notation. Thank you! |
Adds an file check for the database configuration and includes
the file only if it exists.
The datasource configuration might not be always available e.g. for
application bootstrapping via a webfront. The patch inits an empty
configuration if no database.php file is present.