Programmer's guide to SMW

From semantic-mediawiki.org
Jump to: navigation, search

Developers who want to support SMW development or develop extensions to SMW can use a number of resources to get started. Of course, it is strongly recommended to be familiar with the usage of SMW as well. Moreover, there is an SMW architecture guide that provides a basic introduction to the main ideas and concepts in SMW from a developer perspective, which should be useful for reading and writing SMW-related code.

All developers who want to contribute code to SMW should carefully read this page.

Contents

[edit] Getting started

The SMW architecture guide provides a basic introduction to the main ideas and concepts in SMW from a developer perspective.

When switching from a user to a developer of SMW, you should also change the configuration of your testing wiki to ensure that you do not overlook possible errors or problems (especially those created by your own code). Please read about how to debug MediaWiki, in particular the section about PHP error reporting. All MediaWiki extensions are expected to run without issuing any PHP notices!

Also take a moment to familiarise yourself with the MediaWiki resources for developers.

[edit] Code documentation

SMW and its extensions try to provide thorough code documentation as part of their program files. An API documentation is automatically generated from this data:

Semantic MediaWiki API documentation

This documentation encompasses SMW, Semantic Result Formats, Semantic Forms, Semantic Drilldown and Semantic Maps. It is rebuilt every day from the current contents of SVN. Further extensions can be added to this documentation if they relate to SMW, are hosted in MediaWiki SVN, and use naming conventions that prevent confusion with the other extensions (which use prefixes SMW, SRF, SF, SD and SM, respectively).

To get a quick overview of the code distribution in SMW, you can have a look at

SMW source code structure

[edit] Security aspects

Web applications with open user communities are specifically threatened by security vulnerabilities. SMW developers are responsible for taking specific care to avoid vulnerabilities of all kinds. Every developer should carefully read the MediaWiki security guidelines for developers.

If vulnerabilities are discovered, special care is needed to minimize the risk of them being exploited. In particular, it is wise to first contact the core developers directly (e.g. send an email to Markus Krötzsch), to ensure that an updated version can be released before the bug is public. Also note that the project SVN is public and can be monitored by potential attackers. So commit messages like "Fixed critical security vulnerability" can also be problematic. For more information on handling security problems in open source software, see [1].

[edit] Committing code or patches to SVN

Anyone who commits code to SVN has a special responsibility to check that the guidelines on this page are met, whether or not he was the one who wrote the code in the first place. Check that the following has been done before committing code:

Again: All code must be read and tested by the person committing it to SVN. These tasks can also be distributed among several SMW developers who have commit permissions, but ultimate responsibility is always with the person who does the commit. This is especially important for code coming from contributions via Bugzilla or email. Code from such sources must be considered as unreviewed and untested. Of course, if the contributor is experienced, then the code will be in such a readable and well-documented shape that the remaining work on the side of the committer is very little. Contributors should be pointed to this page to improve their code so that they can speed up the processing of their contribution.

[edit] Improving your programming/testing environment

It is useful to setup the local wiki installation in a way that helps to detect and track down problems quickly. On the one hand, it is useful to use not-so-common installation settings to ensure that they are tested at some point:

On the other hand, some PHP-specific settings are useful for find code problems:

[edit] Programming style

SMW and many of its extensions stick to strict naming conventions and code styles based on the MediaWiki coding conventions. The following guidelines apply to SMW, but can often be adopted to other extensions by just changing the prefix SMW.

[edit] Files and folders

[edit] Encoding

[edit] PHP

[edit] Naming conventions

In general, all names are written CamelCase, although methodNames and variableNames typically start with lower case letters.

[edit] Code layout and indenting

In general, code layout is guided by the MediaWiki coding conventions. Please be sure to read this document.

[edit] JavaScript

[edit] Naming conventions

In general, all names are written CamelCase, although methodNames and variableNames typically start with lower case letters.

[edit] Code layout and indenting

No general code layout for SMW's JavaScript has been proposed or implemented yet.

[edit] Documentation

The SVN-version must be deployable at 90% of the time. Update INSTALL whenever needed! Provide update instructions and methods in case of incompatible changes.

[edit] Creating result formats

See this page on how to create result formats.

[edit] Getting support

The SMW Project welcomes all potential contributors and extension developers. Developers can discuss on the SMW developer mailing list, which can also be used to contact the SMW core developers. The SMW Project welcomes bug reports via MediaZilla, which can also be used for feature requests.

Commercial support, custom development projects, and trainings may also be available (depending on your physical location and project specifications) – please contact Markus Krötzsch for further information.

[edit] Testing

[edit] SMW System Testing

[edit] SMW Unit Testing

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox