propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 393 forks source link

Non-static method Propel\Runtime\ActiveQuery\ModelCriteria::delete()` cannot be called statically #2009

Open phpfui opened 2 weeks ago

phpfui commented 2 weeks ago

Getting the following error from the code generated by propel init:

Fatal error: Uncaught Error: Non-static method Propel\Runtime\ActiveQuery\ModelCriteria::delete()` cannot be called statically in C:\websites\php-orm-sql-benchmarks\SOB\Propel2\Base\EmployeeQuery.php on line 222

Indeed, ModelCriteria::delete is not static.

Running PHP 8.2.13 (but this is not a PHP issue, PHP is reported the error correctly)

Composer:

"propel/propel": "2.0.0-beta4",

The generated method in question:

    public function delete(?ConnectionInterface $con = null) : int
    {
        if (null === $con) {
            $con = Propel::getServiceContainer()->getWriteConnection(EmployeeTableMap::DATABASE_NAME);
        }

        $criteria = $this;

        // Set the correct dbName
        $criteria->setDbName(EmployeeTableMap::DATABASE_NAME);

        // use transaction because $criteria could contain info
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
        return $con->transaction(static function() use ($con, $criteria) {
            $affectedRows = 0; // initialize var to track total num of affected rows

            EmployeeTableMap::removeInstanceFromPool($criteria);

            $affectedRows += ModelCriteria::delete($con);  // this is line 222
            EmployeeTableMap::clearRelatedInstancePool();

            return $affectedRows;
        });
    }