Page MenuHomePhabricator

Current conventions for declaring schema are repetitive and could lead to collisions
Closed, DeclinedPublic

Description

02:51 <spagewmf> What if two pieces of code wanted to log to the same schema but nominated different versions? I guess it's unlikely but seems fragile. Maybe you say you want GettingStarted, 5432101 and don't get to give it a module name
02:52 <ori-l> $wgResourceModules[ 'schema.GettingStarted@4993508' ] = array( ... )
02:52 <ori-l> ?
02:53 <ori-l> there would work as-is right now
02:53 <ori-l> we don't do anything special with the module name
02:53 <ori-l> you can name the module after a pet goldfish for all the extension cares
02:54 <ori-l> but if there's an established convention, there's a chance of a collision, it's true
02:54 <spagewmf> Yes we could have that convention. But I'm thinking you wouldn't even name the schema in wgResourceModules, you'd just say depencySchema => 'GettingStarted@4993508' in the definition of a module that needs it and that would give you the schema.
02:55 <ori-l> yes, that would work -- I don't think RL would choke on an unfamiliar key
02:56 <ori-l> another possibility would be to write a function that takes a schema name and an ID, declares the resource loader module, and returns its name, so you would:
02:56 <ori-l> 'dependencies' => array( 'jquery.cookie', 'jquery.json', efSchemaModule( 'GettingStarted', 4993508 ) )
02:57 <ori-l> adding a key would be cleaner
02:58 <spagewmf> Yeah, something like that.
02:58 <ori-l> it could also solve the current duplication, which I loathe.. the $wgResourceModules[ 'schema.Foo' ] = array( 'schema' => 'Foo', ... )
02:59 <ori-l> i like your suggestion better


Version: unspecified
Severity: normal

Details

Reference
bz43818

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:33 AM
bzimport set Reference to bz43818.

I'm not convinced that using two versions of the same schema is a feature.

If there's a collision, it's pretty easy to check which won with:

/load.php?debug=true&modules=schema.SchemaName&only=scripts

If that happens, though, it probably means a schema is being used for two different purposes, in which case it should be forked on Meta.

As far as I can tell, all modules have to have names. It would be confusing otherwise, and I don't think ResourceLoader supports it technically.

I also don't see how:

'dependencies' => array( 'jquery.cookie', 'jquery.json',
efSchemaModule( 'GettingStarted', 4993508 ) )

could work without modifying e.g. ResourceLoaderFileModule to know about EventLogging, which would be bad.

[moving from MediaWiki extensions to Analytics product - see bug 61946]