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

Bug: Email config in the .env doesn't appear as expected #7077

Closed
totoprayogo1916 opened this issue Jan 10, 2023 · 5 comments · Fixed by #7078
Closed

Bug: Email config in the .env doesn't appear as expected #7077

totoprayogo1916 opened this issue Jan 10, 2023 · 5 comments · Fixed by #7078
Labels
4.3 bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@totoprayogo1916
Copy link
Contributor

PHP Version

7.4

CodeIgniter4 Version

4.3.0

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

cli-server (PHP built-in webserver)

Database

No response

What happened?

# .env
email.fromEmail = 'XYZ'

v4.2.12
image

v4.3.0
image

Steps to Reproduce

just set .env

# .env
email.fromEmail = 'XYZ'

Expected Output

Same as in the previous version.

Anything else?

No response

@totoprayogo1916 totoprayogo1916 added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 10, 2023
@totoprayogo1916
Copy link
Contributor Author

I guess all variables with no default content will show "undefined".

@kenjis
Copy link
Member

kenjis commented Jan 10, 2023

It seems get_object_vars() does not return uninitialized properties.

@paulbalandan
Copy link
Member

It seems get_object_vars() does not return uninitialized properties.

It seems not.

Uninitialized properties are considered inaccessible, and thus will not be included in the array.
https://www.php.net/manual/en/function.get-object-vars.php

@kenjis
Copy link
Member

kenjis commented Jan 10, 2023

Workaround:

--- a/app/Config/Email.php
+++ b/app/Config/Email.php
@@ -6,9 +6,9 @@ use CodeIgniter\Config\BaseConfig;
 
 class Email extends BaseConfig
 {
-    public string $fromEmail;
-    public string $fromName;
-    public string $recipients;
+    public string $fromEmail  = '';
+    public string $fromName   = '';
+    public string $recipients = '';
 
     /**
      * The "user agent"

Or

--- a/app/Config/Email.php
+++ b/app/Config/Email.php
@@ -6,9 +6,9 @@ use CodeIgniter\Config\BaseConfig;
 
 class Email extends BaseConfig
 {
-    public string $fromEmail;
-    public string $fromName;
-    public string $recipients;
+    public $fromEmail;
+    public $fromName;
+    public $recipients;
 
     /**
      * The "user agent"

@kenjis
Copy link
Member

kenjis commented Jan 10, 2023

I sent a PR: #7078

@kenjis kenjis added the 4.3 label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants