Page MenuHomePhabricator

[SPIKE] Investigate creation of new mobile attribute on preferences fields
Closed, DeclinedPublic

Description

Context

When a preference is created, different attributes are added to it, such as type, section, and label-message. See an example here. By adding a new mobile attribute, T317110 and T311719 would be easier to solve because we could leverage that attribute.

We should research the feasibility of adding a new attribute when building the preferences associative array.

Questions that need answers

  • Can a new attribute be added?
  • What files would need to be potentially modified?
  • Is there any existing documentation on how to add an attribute?
  • Where would we need to add documentation?

Event Timeline

I had a couple of thoughts:

  • all of the questions here are can we / how could we questions; we should also have some should we questions; like what are the pitfalls of adding device-centric attributes to preferences?
  • we should probably also ask questions about what this attribute should look like. eg. I've seen desktop/mobile differentiated with parameters like targets/platform => ['desktop', 'mobile'] in mobileFrontend and wikimediaEvents.

since we have been having a discussion on if there should be items hidden from end users (and I don't believe we have an agreed upon solution) I would question the wisdom of adding items to one platform [mobile] and not the other [desktop]. Could this cause an issue if a user expects something to be there on desktop because it was on mobile. It just seems that this is the opposite of the other ticket [T311719] we have still not decided is a good next step to do. By having mobile applications for cell phones, it seems that we may be supporting both older phones with their own inherent issues as well as other handheld devices, such as 'off brand' tablets.
Otherwise, I'd have to ask exactly what it is that someone would like added.

Have we decided if this is even something that we should be spending time on? Has there been a request for this?

We should research the feasibility of adding a new attribute when building the preferences associative array, in the example code (for my clarification) the array is $defaultPreferences. But, I don't really understand what each attribute attributes' within the $defaultPreferences - or is that what is being shown in the link in the Context

$defaultPreferences['somePreference'] = [
			'type' => 'info'  // what does this mean? what types can be used, why is it used,
			'raw' => true,'  // what does this mean? what types can be used, why is it used, if is bool, then if true (or false) what does that mean?
			'label-message' => 'prefs-user-someTypeTranslatable-label',
			'default' => 'someStuffLooksLikeStings',  // what does this mean? what types can be used, why is it used,
			'section' => 'personal/info', //does this mean the location of the preference display?
		];

Have we decided if this is even something that we should be spending time on?
Has there been a request for this?

Product and design tasked us with hiding preferences on mobile if they don't impact the mobile experience here: T311719
This spike is for researching a possible approach to that task.

We should research the feasibility of adding a new attribute when building the preferences associative array, in the example code (for my clarification) the array is $defaultPreferences. But, I don't really understand what each attribute attributes' within the $defaultPreferences - or is that what is being shown in the link in the Context

$defaultPreferences['somePreference'] = [
			'type' => 'info'  // what does this mean? what types can be used, why is it used,

As we talked about in T317117, that's for the form typemap
https://doc.wikimedia.org/mediawiki-core/master/php/HTMLForm_8php_source.html#l00154

			'raw' => true,'  // what does this mean? what types can be used, why is it used, if is bool, then if true (or false) what does that mean?

I believe this is the display format; from the same source file:
https://doc.wikimedia.org/mediawiki-core/master/php/HTMLForm_8php_source.html#l00314

			'label-message' => 'prefs-user-someTypeTranslatable-label',
			'default' => 'someStuffLooksLikeStings',  // what does this mean? what types can be used, why is it used,

They are default values. The type will correlate to the field (although in my experience preference values generally end up as strings in the DB); same goes for the logic to set the default. There are lots of examples in:
https://doc.wikimedia.org/mediawiki-core/master/php/DefaultPreferencesFactory_8php_source.html
For the raw display type, the value can be markup.

			'section' => 'personal/info', //does this mean the location of the preference display?
		];

These are used as the key for the different sections of the form. You can see how it works by looking at the pref form class:
https://doc.wikimedia.org/mediawiki-core/master/php/PreferencesFormOOUI_8php_source.html

My feeling (and to the best of my knowledge) best practice is to put the definition of a passed in variable object ect. into the php doc at the beginning of the class, function, or declared variable. That is the point of my comment

Samwalton9-WMF subscribed.

We're not doing this work for the time being.