Closed sandippingle closed 2 months ago
Regarding the reflection deprecation, that point seems valid. Those lines could probably be replaced with:
$class=new ReflectionClass($this->localeClass);
$class->setStaticPropertyValue('dataPath',$value);
Regarding SQLite3 enableExceptions(), I don't see that being used anywhere in framework code?
PHP 8.3 introduces several deprecations that impact the current codebase. Specifically:
Saner Increment/Decrement Operators
ReflectionProperty::setValue() Method
setLocaleDataPath
method to comply with the new requirement of passing null
as the first parameter when setting static properties.public function setLocaleDataPath($value)
{
$property = new ReflectionProperty($this->localeClass, 'dataPath');
if ($property->isStatic()) {
$property->setValue(null, $value);
} else {
$property->setValue($this, $value);
}
}
SQLite3 Exception Handling
SQLite3::enableExceptions(false)
.try {
$db = new SQLite3('database.db');
$db->enableExceptions(true);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
Code Audit and Refactoring
Testing
Update Dependencies
Documentation
Hope this helps out!
Regards.
@TheGithubDev was the post above generated with AI? Is SQLite3 enableExceptions() used anywhere in framework code?
Hi. When will PHP 8.3 support be released for Yii 1.1? Thank you.
@christophwariszlovich You can use https://github.com/yiisoft/yii/pull/4553 for now and please report any new issues you can find :)
@christophwariszlovich You can use #4553 for now and please report any new issues you can find :)
Issue that I found:
$criteria = new CDbCriteria();
$criteria->limit = 10;
$bookings = Booking::model()->findAll($criteria);
Code causes this error:
PHP Error[2]: foreach() argument must be of type array|object, null given
in file /var/www/html/appname/vendor/yiisoft/yii/framework/db/schema/CDbCriteria.php at line 159
#0 /var/www/html/appname/vendor/yiisoft/yii/framework/base/CApplication.php(832): CErrorHandler->handle()
#1 /var/www/html/appname/vendor/yiisoft/yii/framework/db/schema/CDbCriteria.php(159): CConsoleApplication->handleError()
#2 /var/www/html/appname/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(330): CDbCriteria->__construct()
#3 /var/www/html/appname/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1410): Booking->getDbCriteria()
#4 /var/www/html/appname/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1352): Booking->applyScopes()
#5 /var/www/html/appname/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1479): Booking->query()
#6 /var/www/html/appname/api/protected/commands/ToolsCommand.php(4305): Booking->findAll()
#7 unknown(0): ToolsCommand->actionTest()
#8 /var/www/html/appname/vendor/yiisoft/yii/framework/console/CConsoleCommand.php(177): ReflectionMethod->invokeArgs()
#9 /var/www/html/appname/vendor/yiisoft/yii/framework/console/CConsoleCommandRunner.php(71): ToolsCommand->run()
#10 /var/www/html/appname/vendor/yiisoft/yii/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#11 /var/www/html/appname/vendor/yiisoft/yii/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#12 /var/www/html/appname/api/protected/yiic.php(23): CConsoleApplication->run()
#13 /var/www/html/appname/api/protected/yiic(4): require_once()
@christophwariszlovich That doesn't look like a PHP 8.3 error at first sight, looks like an application-specific error with your Booking class default scopes or dbcriteria. You probably get the same error message on earlier PHP versions.
@marcovtwout We have the app running on PHP 5.6 and PHP 8.0.18 running where I dont get the error, we were looking to upgrade to 8.3 and encountered this error. Will check if its a possible problem on our side. Thank you.
@marcovtwout Thank you for pointing me in the right direction. There was a defaultScope function in the model but it didnt return anything!
@marcovtwout I found an issue with the function initConnection in CDbConnection class. As of PHP 8.1 the MySQL driver will convert int and float to the PHP data types (see here: https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.mysql).
In Yii 1.1 there is already code for this but it only applies to sqlite driver:
if(PHP_VERSION_ID >= 80100 && strncasecmp($this->getDriverName(),'sqlite',6)===0)
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
For our application we need the values to be strings, so I overwrote the function in an own class. But I think this should be fixed, as this might legacy code to break when using PHP >= 8.1.
Thank you.
@christophwariszlovich We are using the same behavior here as Yii2 is doing. I'm not entirely sure why, but Yii2 only applies ATTR_STRINGIFY_FETCHES for sqlite. One could argue it's not really a bug/regression but more of a typing improvement in the underlying PDO library.
If your application wants the old behavior, you can implement it like this:
Yii::app()->db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
(or in the application config under 'db' => [..., 'attributes' => [PDO::ATTR_STRINGIFY_FETCHES => true]
Fixed with https://github.com/yiisoft/yii/pull/4553
What steps will reproduce the problem?
PHP Deprecated the following features/functions in their release of 8.3:
https://www.php.net/manual/en/migration83.deprecated.php
Saner Increment/Decrement operators
Reflection
Calling ReflectionProperty::setValue() with only one parameter is deprecated. To set static properties, pass null as the first parameter.
Possibly impacted code:
SQLite3
Using exceptions is now preferred, warnings will be removed in the future. Calling SQLite3::enableExceptions(false) will trigger a deprecation warning in this version.
How can we plan PHP 8.3 compatibility?
Additional info