-
Notifications
You must be signed in to change notification settings - Fork 145
Description
PHP Version
8.5.1
CodeIgniter4 Version
4.6.4
Shield Version
1.2.0
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
MariaDB 10.11
Did you customize Shield?
No
What happened?
WARNING - 2025-12-30 19:50:50 --> [DEPRECATED] Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in VENDORPATH\codeigniter4\shield\src\Models\CheckQueryReturnTrait.php on line 91. 1 VENDORPATH\codeigniter4\shield\src\Models\CheckQueryReturnTrait.php(81): CodeIgniter\Shield\Models\BaseModel->getPropertyDBDebug() 2 VENDORPATH\codeigniter4\shield\src\Models\CheckQueryReturnTrait.php(29): CodeIgniter\Shield\Models\BaseModel->restoreDBDebug() 3 VENDORPATH\codeigniter4\shield\src\Models\LoginModel.php(87): CodeIgniter\Shield\Models\BaseModel->checkQueryReturn(191) 4 VENDORPATH\codeigniter4\shield\src\Authentication\Authenticators\Session.php(299): CodeIgniter\Shield\Models\LoginModel->recordLoginAttempt('email_password', 'xxxxx@xxxxxx.com', true, 'xxx.xxx.xxx.xxx', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0', 1) 5 VENDORPATH\codeigniter4\shield\src\Authentication\Authenticators\Session.php(176): CodeIgniter\Shield\Authentication\Authenticators\Session->recordLoginAttempt([...], true, 'xxx.xxx.xxx.xxx', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0', 1) 6 VENDORPATH\codeigniter4\shield\src\Controllers\LoginController.php(71): CodeIgniter\Shield\Authentication\Authenticators\Session->attempt([...]) 7 SYSTEMPATH\CodeIgniter.php(933): CodeIgniter\Shield\Controllers\LoginController->loginAction() 8 SYSTEMPATH\CodeIgniter.php(507): CodeIgniter\CodeIgniter->runController(Object(CodeIgniter\Shield\Controllers\LoginController)) 9 SYSTEMPATH\CodeIgniter.php(354): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false) 10 SYSTEMPATH\Boot.php(363): CodeIgniter\CodeIgniter->run() 11 SYSTEMPATH\Boot.php(68): CodeIgniter\Boot::runCodeIgniter(Object(CodeIgniter\CodeIgniter)) 12 FCPATH\index.php(65): CodeIgniter\Boot::bootWeb(Object(Config\Paths))
Steps to Reproduce
- Use Shield's default
LoginControllerwith Session authenticator - Attempt to log in via
LoginController->loginAction() - The warning is triggered during
LoginModel->recordLoginAttempt()which callsBaseModel->checkQueryReturn() - The
CheckQueryReturnTrait->getPropertyDBDebug()method usesReflectionProperty::setAccessible()on line 91
Expected Output
No deprecation warnings should appear. The setAccessible() call should be removed as it's unnecessary in PHP 8.1+ (all properties are accessible by default via reflection).
Anything else?
- This warning appears on every login attempt when using the default Shield login flow
- The warning is non-fatal but clutters logs and will become an error in future PHP versions
- The fix should be straightforward: remove the
setAccessible()call fromCheckQueryReturnTrait.phpline 91, as it has no effect in PHP 8.1+
Related Code References
- Shield Repository: https://github.com/codeigniter4/shield
- PHP 8.5 Deprecation Notice: https://www.php.net/manual/en/migration85.deprecated.php#migration85.deprecated.reflectionproperty.setaccessible
- PHP ReflectionProperty::setAccessible(): https://www.php.net/manual/en/reflectionproperty.setaccessible.php
Suggested Fix
Remove the setAccessible() call in CheckQueryReturnTrait.php around line 91, as it's unnecessary in PHP 8.1+:
// Before (deprecated):
$reflection->setAccessible(true);
$value = $reflection->getValue($this);
// After (PHP 8.1+ compatible):
$value = $reflection->getValue($this);### Impact
- Severity: Low (warning only, not fatal)
- Frequency: Every login attempt
- User Impact: None (functionality works correctly)
- Developer Impact: Log clutter, future compatibility concern
~ Report made with the help of Cursor