codeigniter4 / shield

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

refactor: remove hard coded `'Y-m-d H:i:s'` #1027

Closed kenjis closed 6 months ago

kenjis commented 6 months ago

Description See https://github.com/codeigniter4/shield/issues/608 and https://github.com/codeigniter4/CodeIgniter4/pull/8538

Checklist:

kenjis commented 6 months ago

I sent PR to fix: https://github.com/codeigniter4/CodeIgniter4/pull/8543

 ------ --------------------------------------------------------------------- 
  Line   src/Controllers/MagicLinkController.php                              
 ------ --------------------------------------------------------------------- 
  108    Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
 ------ --------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   src/Models/LoginModel.php                                            
 ------ --------------------------------------------------------------------- 
  77     Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
 ------ --------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   src/Models/RememberModel.php                                         
 ------ --------------------------------------------------------------------- 
  58     Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
 ------ --------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   tests/Authentication/MagicLinkTest.php                               
 ------ --------------------------------------------------------------------- 
  113    Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
  135    Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
 ------ --------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   tests/Controllers/MagicLinkTest.php                                  
 ------ --------------------------------------------------------------------- 
  102    Parameter #1 $row of method CodeIgniter\Model::insert() expects      
         array<int|string, float|int|string|null>|object|null, array<string,  
         CodeIgniter\I18n\Time|int|string|null> given.                        
 ------ --------------------------------------------------------------------- 

Error:  [ERROR] Found 6 errors

https://github.com/codeigniter4/shield/actions/runs/7895251231/job/21547330117?pr=1027

kenjis commented 6 months ago

dateFormat has been added to CI version 4.5 In contrast, Shield supports version 4.3.5. What effect will these changes have on older versions?

In my understanding, there is no changes. The Time instance that is passed to a Model will be converted to a string with hard coded Y-m-d H:i:s in the Model. See https://github.com/codeigniter4/CodeIgniter4/blob/3595944eac90df7e499403bad8767935c41488d9/system/BaseModel.php#L1316-L1320

datamweb commented 6 months ago

@kenjis thank you!