Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Model, added Loader::isRegistered, fixed Metadata behaviour #16392

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

rudiservo
Copy link
Contributor

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:

Refactored the Model::doLowUpdate for better seperation of dynamicUpdate from normal full update.
Added better error reporting adding the class on which it happened.
Added Model::appendMessagesFrom for code quality and added the model name to the message MetaData
Added Model and relatedName to Message MetaData in several lines where there was no reference to model and/or relation where the non-exception failure occurred.

Thanks

@rudiservo rudiservo changed the title Refactored Model, better error reporting, added appendMessagesFrom, added Loader::isRegistered Refactored Model, added Loader::isRegistered, fixed Metadata behaviour Aug 6, 2023
@niden
Copy link
Member

niden commented Aug 8, 2023

@rudiservo Can you split that into much smaller PRs please? Say one for the loader, one for the messages changed/exceptions, one for metadata etc.

There are a lot of areas that I do not understand what the goal of the changes are, for instance the keys for metadata are no longer held in lowercase.

@rudiservo
Copy link
Contributor Author

@niden sure, I did tried to make seperate pull requests, github just put it into one dont know why.
If you don't mind giving me a hint on how to make it, and if there is an easy way to just split code from a commit?

Metadata changes are on their own commit.

Metadata keys are in lowercase, using get_class_lower(), what they are is no longer concat with the schema and source in case of the actual MetaData, ColumnMap was always lowercase but it used two functions, get_class() and strtolower().

Schema and source are pulled from the manager, and the manager associates them with the get_class_lower() only, makes no sense to make a metadata key with all that when the information is only associated with the full namespace class itself.

In the Model Messages the changes are for better error reporting, many times I do not know where the error is and I have to do a game of var_dump() die() or figuring out where in xdebug trace it failed.

The postSaveRelatedRecords is to seperate the logic through from normal, it makes code analysis simpler has well has less checks, maybe slight performance improvement.
The doLowUpdate is to seperate dynamicUpdate logic from normal full update, this helps a lot also for code analysis and has less checks, it either is or is not, maybe slight performance improvement.
Both are not behaviour changes, just code reorganization.

@rudiservo
Copy link
Contributor Author

rudiservo commented Aug 8, 2023

And metadata::initialize was overblown with code that was not supposed to be there and the calls to it actually should only call initializeMetadata or InitializeColumnMap, now it's cleaner, probably very very very very very small performance improvement.

CHANGELOG-5.0.md Outdated Show resolved Hide resolved
@niden niden requested a review from Jeckerson August 9, 2023 13:04
@rudiservo rudiservo force-pushed the 5.0.x branch 2 times, most recently from 1192ed1 to 6c6eba3 Compare August 9, 2023 15:34
@Jeckerson Jeckerson merged commit d09643f into phalcon:5.0.x Aug 10, 2023
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants