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

Different approach for extension check, refs 4119, 4190 #4438

Merged
merged 1 commit into from Jan 19, 2020

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented Jan 19, 2020

This PR is made in reference to: #

This PR addresses or contains:

When SetupCheck was introduced as part of #4041 and extended in #4119, #4190 the class became increasingly convoluted with different HTML snippets to create a meaningful error message to the user. The HTML code has been "outsourced" to templates with the definition of what should be generated now being defined by setupcheck.json with the following errors keys:

  • ERROR_EXTENSION_LOAD
  • ERROR_EXTENSION_INVALID_ACCESS
  • ERROR_EXTENSION_REGISTRY
  • ERROR_EXTENSION_DEPENDENCY
  • ERROR_EXTENSION_DEPENDENCY_MULTIPLE
  • ERROR_EXTENSION_INCOMPATIBLE
  • ERROR_SCHEMA_INVALID_KEY, and
  • MAINTENANCE_MODE

There was also a mix of MW message keys and canonical text making the handling inconsistent in case SMW wasn't loaded those MW keys couldn't be used therefore to avoid cluttering text representations, setupcheck.i18n.json now contains keys and translatable text that is independent of the state of MW and SMW.

#4190 added a check for wfLoadExtension( 'SemanticMediaWiki' ) to detect "doubly" invocation but made it dependent to call ExtensionRegistry::getInstance and left a certain use case uncovered #4190#issuecomment-517948006 making the solution sub-optimal. Instead of relying on ExtensionRegistry we'll register a UncaughtExceptionHandler and inspect those errors we are interested in and make them to look "nice" with some extra context. This also provides us with a means to the fetch additional errors (ERROR_EXTENSION_DEPENDENCY, ERROR_EXTENSION_INCOMPATIBLE etc.) that would otherwise be displayed as "ugly" exception without any context.

This PR includes:

  • Tests (unit/integration)
  • CI build passed

Examples

image

image

image

image

image

image

image

@mwjames mwjames added the enhancement Alters an existing functionality or behaviour label Jan 19, 2020
@kghbln kghbln added this to the SMW 3.2.0 milestone Jan 19, 2020
@kghbln kghbln added the wikidocu missing Code changes (mostly features) what have not yet been documented label Jan 19, 2020
@mwjames
Copy link
Contributor Author

mwjames commented Jan 19, 2020

@kghbln As outlined above, the error code (e.g ERROR_SCHEMA_INVALID_KEY) now defines a form in [0] to appear consistently with a similar look and feel (and adding a new error code is easily done by adding a new form definition) while message keys (e.g. smw-setupcheck-invalid-upgrade-key) are defined in [1] to be independent of MW and the Message class. [1] works even if SMW isn't loaded and can be translated in case the need arises.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/bcb2bd17d70f2b296e54e43028cd7e0b39139a8b/data/template/setupcheck/setupcheck.json
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/bcb2bd17d70f2b296e54e43028cd7e0b39139a8b/i18n/local/setupcheck.i18n.json

@mwjames
Copy link
Contributor Author

mwjames commented Jan 19, 2020

(and adding a new error code is easily done by adding a new form definition)

An upcoming PR will add ERROR_DB_REQUIREMENT_INCOMPATIBLE as I need to increase the minimum requirement for postgres for a different feature.

@mwjames mwjames merged commit 23439ac into master Jan 19, 2020
1 check passed
@mwjames mwjames deleted the extension-check branch Jan 19, 2020
@mwjames
Copy link
Contributor Author

mwjames commented Jan 19, 2020

As for the mentioned codes, [0] contains a short description for each of them.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/SetupCheck.php#L20-L60

mwjames added a commit that referenced this pull request Jan 19, 2020
mwjames added a commit that referenced this pull request Jan 19, 2020
@mwjames mwjames restored the extension-check branch Jan 19, 2020
mwjames added a commit that referenced this pull request Jan 19, 2020
mwjames added a commit that referenced this pull request Jan 19, 2020
@mwjames
Copy link
Contributor Author

mwjames commented Jan 25, 2020

I started to add some rudimentary information in [0].

[0] https://www.semantic-mediawiki.org/wiki/Help:Setup_check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Alters an existing functionality or behaviour wikidocu missing Code changes (mostly features) what have not yet been documented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants