You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On my migration from v.4 to v.5, I have already updated all the namespaces that have changed, and started the testing of each API route using Codeception, I have managed to pass all the GET requests and now going through the POST requests.
The "User" class is the model, which has some validation methods, sanitation methods, beforeCreate, etc. The User class extends the model created by devtools, which extends from Phalcon\Mvc\Model.
$userModel = new User();
$userModel->setName($parameters['name']);
$userModel->setEmail($parameters['email']);
$userResult = $userModel->save();
The "save" method from the model is throwing a fatal error. I do not know the value from the static method "readMetaDataIndex" because I am not able to catch the error.
<b>Fatal error</b>: Phalcon\Mvc\Model\MetaData::readMetaDataIndex(): Return value must be of type ?array, string returned in <b>Unknown</b> on line <b>0</b><br />
UPDATE:
As mentioned before, the error is generated on readMetaDataIndex method.
final public function readMetaDataIndex(<ModelInterface> model, int index) -> array | null
{
var key;
let key = this->getMetaDataUniqueKey(model);
if likely key !== null {
return this->metaData[key][index];
}
return null;
}
I have found that the error is thrown for "this->metaData[key][index]" when the index=8, this index belongs to the const MODELS_IDENTITY_COLUMN = 8; This is an extract from the metaData property, the index 8 is the only one that is a string, the rest are arrays:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
On my migration from v.4 to v.5, I have already updated all the namespaces that have changed, and started the testing of each API route using Codeception, I have managed to pass all the GET requests and now going through the POST requests.
The "User" class is the model, which has some validation methods, sanitation methods, beforeCreate, etc. The User class extends the model created by devtools, which extends from Phalcon\Mvc\Model.
The "save" method from the model is throwing a fatal error. I do not know the value from the static method "readMetaDataIndex" because I am not able to catch the error.
UPDATE:
As mentioned before, the error is generated on readMetaDataIndex method.
I have found that the error is thrown for "this->metaData[key][index]" when the index=8, this index belongs to the const MODELS_IDENTITY_COLUMN = 8; This is an extract from the metaData property, the index 8 is the only one that is a string, the rest are arrays:
The "identityField" is generated on the "getMetaData" method from the "Introspection", the assignation is as follow:
As you can see here, this value is assigned as a string, but the readMetaDataIndex method is expected to return an array or null.
Any help will be appreciated.
Regards,
Beta Was this translation helpful? Give feedback.
All reactions