[ticket/15190] Consolidate validation methods in metadata manager#4807
[ticket/15190] Consolidate validation methods in metadata manager#4807javiexin wants to merge 7 commits intophpbb:masterfrom
Conversation
Added tests PHPBB3-15190
|
All validate_* methods should be marked @internal or @deprecated with a note saying that in 4.0 they won't be public anymore. About the validate() method, I don't really like how it works now. I think that all should validate everything. Maybe we can work 2 arrays:
e.g: |
|
I like your proposal. If we are refactoring validate completely, maybe worth adding a validation (and get) for version_check, quite used in the code. While we are at this, what do you think about making metadata completely "opaque", that is, encapsulated by extension manager, using it as the only accessor to metadata manager, providing proxy methods in extension manager to validate and get metadata? That would be a separate (but related) PR. Same thing could be done for extension objects themselves (only |
|
Ok, I have the code, as follows:
I could revert back to three arrays, but would be as complex, and more verbose... Your choice :) As for the other comment, I will mark all validate_ methods as internal (not deprecated) as they will continue existing, although moving them to protected visibility (as of 4.0, right?). For now, I have not changed the semantics of any validation (all is display + enable, so really, all things that are validated are included here). |
|
Lets see how it looks. About merging the extension manager and the metadata manager I think it is a bad idea, lets keep concerns separated (I think we even should move the validation to another class) |
Change validate method using a generic config array. PHPBB3-15190
Add @internal warning to all validate_ methods PHPBB3-15190
| $this->metadata_file = $ext_path . 'composer.json'; | ||
|
|
||
| // Initialize validations | ||
| $this->validations = array( |
There was a problem hiding this comment.
Agreed. Didn't do it as I was not sure it was ok for the minimum PHP version.
Will do it tomorrow.
Validate version_check PHPBB3-15190
|
Three commits:
Regarding merging extension manager and metadata manager, I think I miss-explained what I meant. |
Make validation array static PHPBB3-15190
|
@Nicofuma completed what we talked about:
Anything else you think is worth doing here? About making the validation a new class... I don't think so: it is heavily mixed with the getter methods for metadata elements. But maybe we could create a |
Complete the use of version check validation PHPBB3-15190
|
@Nicofuma Anything else left to do here? Is this going forward? |
Use a single method to access all validation options in metadata manager. Before, some validations had their own function, while others shared a single validate method. Now, the validate method acts as a proxy for all others.
Also, with the existing implementation, you should not call validate without calling get_metadata first, as get_metadata was the only way to do the file loading (any call to validate without calling get_metadata first would result in an exception being raised even if the metadata is correct); with this change, the order is irrelevant, and the file is only loaded once. Some uses of get_metadata that were not using the returned data have been replaced with the corresponding validate call.
Checklist:
Tracker ticket:
https://tracker.phpbb.com/browse/PHPBB3-15190