Last modified: 2014-01-20 23:12:54 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 T62213, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 60213 - Type mismatch when caching SMW IDs
Type mismatch when caching SMW IDs
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-18 20:57 UTC by Alexey Demakov
Modified: 2014-01-20 23:12 UTC (History)
4 users (show)

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


Attachments

Description Alexey Demakov 2014-01-18 20:57:04 UTC
MediaWiki 	   1.22.1                (721b9e0) 22:03, 14 January 2014
Semantic MediaWiki (Version 1.9 alpha-3) (9a55761) 19:21, 22 October 2013

mediawiki/extensions/SemanticMediaWiki/includes/storage/SQLStore:

(SMW_Sql3SmwIds.php)SMWSql3SmwIds->setCache() is called from

(SMW_SQLStore3_Queries.php)SMWSQLStore3QueryEngine->getInstanceQueryResult()

with $id that is string, not integer as documented for setCache.

In most cases it is not a problem, php cast values automatically.
But arrays containing ids are serialized 
when hashes for property tables are computed.
In this case, types of ids are important - serialized arrays differs
and md5 hashes also differs.

For example (take a look at s_id or p_id):

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;}}

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";}}

These hashes are used to compare new semantic data 
with current semantic data stored in database to avoid unnecessary writes.

Fortunately functionality is not affected, only performance.

I propose to add explicit type cast in (SMW_Sql3SmwIds.php)SMWSql3SmwIds->setCache() method
to make sure ids are always integer.
Comment 1 MWJames 2014-01-18 21:11:56 UTC
As site note, you may want to use the released 1.9.0.2 version for verification and post a PR via [1].

[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki
Comment 2 Alexey Demakov 2014-01-19 12:05:41 UTC
@MWJames, I've upgraded my SMW to 1.9.0.2, no relevant changes were made.
So, pull request is created.

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


Navigation
Links