Last modified: 2007-10-21 19:49:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T13506, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11506 - Semantic Forms should use SMWStore instead of direct DB access
Semantic Forms should use SMWStore instead of direct DB access
Product: MediaWiki extensions
Classification: Unclassified
SemanticForms (Other open bugs)
All All
: Normal enhancement (vote)
: ---
Assigned To: Yaron Koren
Depends on:
  Show dependency treegraph
Reported: 2007-09-30 00:55 UTC by Louis Gerbarg
Modified: 2007-10-21 19:49 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Initial DB abstraction and 0.7/1.0 compat code (8.93 KB, patch)
2007-10-02 06:53 UTC, Louis Gerbarg

Description Louis Gerbarg 2007-09-30 00:55:58 UTC
Semantic Forms directly accesses a number of SMW's mysql tables. Those tables are implementation detail, and some people may choose to implement something besides the default SMWSQLStore. That will break the current SF. In particular, the following tables are directly accessed:


It appears that boolean may be going away now that enumerations exist, so the first two may need some code, and the last two can probably be deleted along with all the smw_boolean with 1.0.

I don't see any particularly clean way to support this on both SMW 0.7 and SMW 1.0 in the same code. I may get around to doing this in the next few days, but if I do the patch will definitely break 0.7 support.
Comment 1 Yaron Koren 2007-09-30 14:56:03 UTC
This is great, I'm looking forward to your new code - it could be that SMW 1.0-compatibility is just around the corner. I don't know if this counts as a clean solution, but I think the best way to handle these code sections is with if-statements, calling either the old or the new code depending on the SMW version. The check might look something like:

if (SMW_VERSION <= 0.7) {...

I don't know if that will work, given that all the recent version numbers are alphanumeric instead of just numbers, but there something along those lines that will work.
Comment 2 Yaron Koren 2007-09-30 18:23:20 UTC
This if-statement should work in all cases, I think; the best solution seems to be to just check the first character:

$smw_version = SMW_VERSION;
if ($smw_version{0} == '0') {...

This should return 'true' if SMW is anything less than 1.0.
Comment 3 Louis Gerbarg 2007-09-30 21:21:09 UTC
The issue is that some things would need to remain defined in the enclosing scope:

if ($smw_version{0} == '0') {
    $db = ...;
    //do stuff with DB


if ($smw_version{0} == '0') {
    $db = ...;
    //do stuff with DB

May be different than:

$db = ...;

if ($smw_version{0} == '0') {
    //do stuff with DB


if ($smw_version{0} == '0') {
    //do stuff with DB

Now doing it the second way is not a huge deal, except that variable is still accessible in the context, so we need to put big comments on it that people are not supposed to use them, or effectively patches may rebreak the encapsulation. IOW, it is not a functional issue, but in order to keep it working it is an ongoing verification issue.
Comment 4 Yaron Koren 2007-10-01 01:41:46 UTC
The first way should work, no? It should be possible to just always get a new database pointer, and it would solve the encapsulation issues, plus result in cleaner code. I think that way makes sense, if it's possible.
Comment 5 Louis Gerbarg 2007-10-01 03:58:28 UTC
The first way will work in this case. It may slow down the 0.7 code path (hopefully the db module caches the connections underneath). There may be cases where something similar will be an issue because the two code blocks depend on some persistence of the variable. But it is probably not worth worrying about them until we see them come up.
Comment 6 Louis Gerbarg 2007-10-02 06:53:21 UTC
Created attachment 4201 [details]
Initial DB abstraction and 0.7/1.0 compat code
Comment 7 Louis Gerbarg 2007-10-02 06:54:36 UTC
Okay, attached is a first cut. It seperates out 0.7 versus 1.0 functionality at all locations that need different behavior for this. It also implements the new path for the most common case (Edit by Form). The implementation of the broken link form support does not work because it is not a good impedance match for the current API, and I want to think through how to do, since there may be a way to do it more cleanly and efficiently. Additionally, autocomplete on relation is not implemented because its usage was not documented on the extension page. Is it used in the special pages?

Even with those two issues, it still would probably be best to check this in provided I did not break 0.7 support. The first one requires modifications to the base Mediawiki to be exposed anyway. Since in repo 1.0 support was broken by changes to SMW 1.0alpha 2 days ago, there is literally no chance anyone will notice those, and it lays down the initial refactoring needed to support 0.7 and 1.0.

I have not tested this on 0.7, so please make sure it does not break your dev box before you apply it. If you do apply it please make not if it in this bug, but leave the bug open for me to track the ongoing issues.

Also, if you could give me insight on the autocomplete thing, that would be great.
Comment 8 Yaron Koren 2007-10-02 12:27:48 UTC
Thanks for this code, this is really excellent. I have a feeling we're about 80% of the way to full compatibility with both SMW versions. I'll contact you privately about autocompletion.
Comment 9 Louis Gerbarg 2007-10-07 22:34:22 UTC
Heh, they just made more schema changes a few days ago, so I need to more work for this issue. I will should have some more time soon. I have some 1.0 changes unrelated to this particular issue I will put into a new bug.
Comment 10 Yaron Koren 2007-10-21 19:49:31 UTC
Setting to "Fixed" - these specific changes have been implemented, and it looks like SMW 1.0 support is basically working. Any new issues can go into new bugs.

Note You need to log in before you can comment on or make changes to this bug.