Author: allex
Description:
Recorded actions for Selenium IDE, no checks
If there is a subobject with property pointing to some page, sometimes when page is moved (without redirect), semantic data of that object's property (incorrectly) updated to point at new page.
I've found two related problems in source code.
Versions:
MediaWiki 1.21.1 (56e8075)
Semantic MediaWiki (Version 1.9 alpha) (69e25c6)
I use this test case:
- Create page '1' with text '1'
- Create page 'Q' with text {{#ask: [[Type::T]]|?Property|format=table}}
- Check that 'S' is shown in query result table and Property=1
- Move '1' to 'One' without redirect
- Check that 'S' is shown at page 'Q' in query result table and Property=1
- Create page '1' again with text '2'
- Move '1' to 'Two' without redirect
- Check that 'S' is shown at page 'Q' in query result table and Property=Two
but should be Property=1
Analysis:
- wikipage '1' created, s_id=51
- Add semantic info about subobject with two properties:
DatabaseBase::query: INSERT INTO smw_di_wikipage (s_id,p_id,o_id) VALUES ('53','55','51'),('53','56','57')
Add hash about this data:
DatabaseBase::query: UPDATE smw_object_ids SET smw_proptable_hash = 'a:1:{s:15:\"smw_di_wikipage\";s:32:\"c43e412734de47975c15442da48c01ca\";}' WHERE smw_id = '53'
Hash is md5 of this serialized array:
smw_di_wikipage data: a:2:{i:0;a:3:{s:4:"s_id";i:53;s:4:"p_id";i:55;s:4:"o_id";s:2:"51";}i:1;a:3:{s:4:"s_id";i:53;s:4:"p_id";i:56;s:4:"o_id";i:57;}}
- wikipage 'One' created, s_id=60
Move semantic info from '1' to 'One':
DatabaseBase::query: UPDATE wiki_smw_di_wikipage SET s_id = '60' WHERE s_id = '51'
Change references from '1' to 'One':
DatabaseBase::query: UPDATE wiki_smw_di_wikipage SET o_id = '60' WHERE o_id = '51'
BUG: hash is not updated!
It's located somewhere near
SMW_SQLStore3_Writers.php line 711 calls SMWSQLStore3->changeSMWPageID()
SMW_SQLStore3.php line 315 calls SMWSQLStore3Writers->changeTitle()
Refresh semantic data of page 'S' (in update job):
Serialized array:
smw_di_wikipage data: a:2:{i:0;a:3:{s:4:"s_id";s:2:"53";s:4:"p_id";s:2:"55";s:4:"o_id";s:2:"51";}i:1;a:3:{s:4:"s_id";s:2:"53";s:4:"p_id";s:2:"56";s:4:"o_id";s:2:"57";}}
md5 hash: 8ddbfffecc91e9fd86703ef843e2b7a2
BUG: the array describes the same data but hash differs because keys are strings, not integers as before.
I hate dynamic typing!
But because hashes are different we write correct info:
DatabaseBase::query: DELETE FROM wiki_smw_di_wikipage WHERE (s_id='53' AND ((p_id = '55' AND o_id = '60')))
DatabaseBase::query: INSERT INTO wiki_smw_di_wikipage (s_id,p_id,o_id) VALUES ('53','55','51')
DatabaseBase::query: UPDATE wiki_smw_object_ids SET smw_proptable_hash = 'a:1:{s:15:\"smw_di_wikipage\";s:32:\"8ddbfffecc91e9fd86703ef843e2b7a2\";}' WHERE smw_id = '53'
- wikipage '1' created, s_id=51
- wikipage 'Two' created, s_id=61
Move semantic info from '1' to 'Two':
DatabaseBase::query: UPDATE wiki_smw_di_wikipage SET s_id = '61' WHERE s_id = '51'
Change references from '1' to 'One':
DatabaseBase::query: UPDATE wiki_smw_di_wikipage SET o_id = '61' WHERE o_id = '51'
BUG: hash is not updated!
Update job doesn't write correct info because at this time hashes are equal (bug is not compensated as before) and we see Property=Two in query result table.
Version: master
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=60213
Attached: