Skip to content
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

Support using env(DATABASE_URL) #768

Merged
merged 16 commits into from Sep 20, 2019
Merged

Support using env(DATABASE_URL) #768

merged 16 commits into from Sep 20, 2019

Conversation

leofeyer
Copy link
Member

@leofeyer leofeyer commented Sep 17, 2019

This PR supports using env(APP_SECRET), env(DATABASE_URL) and env(MAILER_URL) as recommended in the Symfony 4 best practices. If no env variables are present, a compiler pass dynamically adds them from the parameters.yml configuration, therefore this change is 100% backwards compatible.

@leofeyer leofeyer changed the title Use an .env file instead of a parameters.yml file Support env(DATABASE_URL) and env(MAILER_URL) Sep 19, 2019
@leofeyer leofeyer changed the title Support env(DATABASE_URL) and env(MAILER_URL) Support using env(DATABASE_URL) Sep 19, 2019
@leofeyer
Copy link
Member Author

This one is RTM now IMO.

@leofeyer leofeyer merged commit b184d55 into master Sep 20, 2019
@leofeyer leofeyer deleted the feature/dotenv branch September 20, 2019 19:59
richardhj pushed a commit to richardhj/contao that referenced this pull request Nov 15, 2019
…ao#230)

Description
-----------

Consider the following:
```
$model = new Contao\PageModel();
$model->title = 'Foo';
$model->attach();
```
This works once per table (in this example, `tl_page`), because `Contao\Model\Registry::arrRegistry` then has one key for that table that is `""` (empty string):
```
array(13) {
  // …
  ["tl_page"]=>
  array(58) {
    [1]=>
    object(Contao\PageModel)contao#641 (6) { /* … */ }
    [4]=>
    object(Contao\PageModel)contao#768 (6) { /* … */ }
    // …
    [""]=>
    object(Contao\PageModel)contao#2094 (6) { /* Our Model */ }
  }
  // …
}
```
Once we do the same thing again:
```
$model2 = new Contao\PageModel();
$model2->title = 'Bar';
$model2->attach();
```
we suddenly get an exception:
> The registry already contains an instance for tl_page::id()

Obviously, this is not the expected behavior. The Registry should either categorically allow registering a model without a primary key or categorically not allow it. This fix implements the latter. It does not use `empty()` because that would overshoot and prevent the primary key from being `0` or `"0"`, which may not be recommendable, but does not have to be forbidden in this context.

Commits
-------

3f33fc2 Do not allow registering a Model with an empty primary key
5011f8e Do not allow saving a Model with an invalid primary key
3aaaee2 Revert some changes and allow the primary key to be an empty string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants