codeigniter4 / shield

Authentication and Authorization for CodeIgniter 4
https://shield.codeigniter.com
MIT License
366 stars 133 forks source link

Bug: Call to undefined function CodeIgniter\Shield\Controllers\emailer() #506

Closed Kimotu closed 1 year ago

Kimotu commented 2 years ago

PHP Version

7.4.6

CodeIgniter4 Version

4.2.8

Shield Version

1.0.0-beta.3

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

MariaDB

Did you customize Shield?

No.

No inherited classes, just own views.

What happened?

I upgraded to shield-1.0.0-beta3 (composer upgrade), checked new user creation with mail verification and got Call to undefined function CodeIgniter\Shield\Controllers\emailer().

I looked through the code. Three classes use emailer()

When I add helper('email') before each of the three emailer() calls, everything works as before.

Steps to Reproduce

Upgrade to latest shield via composer and try a function that uses mails.

Expected Output

activation mail, 2FA or magic link mail sent

Anything else?

Was there a helper call in previous version or is something wrong in autoloading the helper class?

datamweb commented 2 years ago

Hi, welcome, We've made some changes to how helpers are loaded. Please run the following command and check again.

Composer Update
kenjis commented 2 years ago

I don't know why this error happens.

This should work, because composer upgrade is an alias for composer update. And Composer will autoload the helpers. https://github.com/codeigniter4/shield/blob/5e6d5175da45b06dbe7d1deda03458d79d45a951/composer.json#L41-L44

jozefrebjak commented 2 years ago

@kenjis I just ran composer update and email_helper.phpis gone. I'm using dev-develop branch

CleanShot 2022-11-05 at 22 20 10@2x

Edit:

I deleted shield folder from vendor and ran composer update and now it's fine. Strange :D

kenjis commented 2 years ago

@jozefrebjak It is very strange! I think composer update does not delete email_helper. I don't know why your helper is gone.