Last modified: 2014-09-26 22:38:27 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 T58257, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 56257 - Site logo should not be an inline background-image in the html output
Site logo should not be an inline background-image in the html output
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.23.0
All All
: Low enhancement (vote)
: 1.25.0 release
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-28 17:07 UTC by Bartosz Dziewoński
Modified: 2014-09-26 22:38 UTC (History)
8 users (show)

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


Attachments

Description Bartosz Dziewoński 2013-10-28 17:07:06 UTC
Let's not put logo URL in an inline background-image style, these can be cached forever and thus are very annoying to change. It should be trivial to make a ResourceLoader module that would just output '#p-logo a { background-image: url($wgLogo); }'.

(This affects Vector and Monobook skins.)
Comment 1 Krinkle 2013-11-15 22:41:41 UTC
Sounds sensible, though maybe avoid adding a new module for it. Perhaps add it to the 'site' module.

On that note, we might also want to move usercssprefs into user (it makes sense to separate a.t.m. because one is embedded as only=styles). And user.groups is separate from 'site' to avoid having 'site' be user specific, it could perhaps be merged into 'user' though.
Comment 2 Gerrit Notification Bot 2013-12-01 00:57:10 UTC
Change 98356 had a related patch set uploaded by Tholam:
Site logo loaded using UserCSSPrefsModule instead of inline

https://gerrit.wikimedia.org/r/98356
Comment 3 Thomas Lam 2013-12-01 19:27:38 UTC
How do I add it to the site module? I tried doing something similar to what's in the UserCSSPreferences but that didn't seem to work.
Comment 4 Bartosz Dziewoński 2013-12-01 20:41:54 UTC
I didn't test the code below, but it should be enough to override the getStyles() method:

class ResourceLoaderSiteModule extends ResourceLoaderWikiModule {
	…
	public function getStyles( ResourceLoaderContext $context ) {
		$styles = parent::getPages( $context );
		$styles['all'][] =
			"#p-logo a { background-image: url($wgLogo); }";
		return $styles;
	}
	…
}
Comment 5 Bartosz Dziewoński 2013-12-01 20:43:08 UTC
(In reply to comment #4)
>         $styles = parent::getPages( $context );

This of course should be getStyles, silly me. And I'm missing
`global $wgLogo;`.
Comment 6 Thomas Lam 2013-12-01 20:57:24 UTC
I tried putting this 
public function getStyles( ResourceLoaderContext $context ) {
	global $wgLogo;
	$styles = parent::getStyles( $context );
	$styles['all'][] = "#p-logo a { background-image: url($wgLogo); }";
	return $styles;
}
in the ResourceLoaderSiteModule class but it doesn't get loaded.  I already got rid of the inline styling but now there's just no logo.
Comment 7 Bartosz Dziewoński 2013-12-01 21:38:32 UTC
Blaaaghh.

I spent way too much time tracking this down.

This is because the module is not loaded at all if its isKnownEmpty() method returns true, and it does return true for ResourceLoaderWikiModule (of which ResourceLoaderSiteModule is a subclass) if none of the pages it's supposed to check exist (as returned by getPages() method).

Of course, on a new wiki none of these pages exist, so the module is not even loaded.

The simplest solution that makes this work is adding `public function isKnownEmpty( ResourceLoaderContext $context ) { return false; }` to ResourceLoaderSiteModule, but this looks like an awful hack. We might want to create a new module after all per comment 0, but I'd like Krinkle to comment on this.

(I knew this is going to cause trouble, and Krinkle, I told you so. :P )
Comment 8 Thomas Lam 2013-12-01 21:40:39 UTC
I'll just go ahead and do it both ways and see which one we like more in the end.
Comment 9 Gerrit Notification Bot 2013-12-01 22:45:46 UTC
Change 98460 had a related patch set uploaded by Tholam:
Create ResourceLoaderLogoModule to load logo

https://gerrit.wikimedia.org/r/98460
Comment 10 Bartosz Dziewoński 2013-12-02 20:16:06 UTC
I had a little chat about this with Krinkle on #wikimedia-dev today.

Basically, it looks like we'll go with the original approach, it just needs some fixes – and while we're at it, let's change the selector for logo from "#p-logo a" to something saner like ".mw-wiki-logo" (and add this class to the appropriate element in the skins themselves).

Sorry, but I don't have much time for Wikimedia things today/tomorrow, so let me just paste the log here:

<Krinkle> MatmaRex: What about the sitelogo thing? Why is extending
  the wikmodule a problem?
<MatmaRex> well, we need to override isKnownEmpty(), which looks hacky
  to me, and might not be the most efficient thing ever in general
<MatmaRex> and we need to combine logic for cache invalidation with
  the existing one
<MatmaRex> both of these mean that we need to much internal knowledge
  of RLWikiModule than i'm comfortable with when subclassing it like
  this
<MatmaRex> (unless i'm missing something obvious to you)
<Krinkle> MatmaRex: overriding isKnownEmpty is fine, because it
  unconditionally adds the css rule. Unless you make that css rule
  optional, there is no need to implement any known-empty logic.
<Krinkle> As for the cache invalidation, that's just parent::() and
  then return max( $parentMTime, wglogomtime )
<Krinkle> which you calculate using the value-hash-cache-timestamp
  logic
<MatmaRex> we have no wglogomtime i'm aware of, unless we store the
  time we last noticed it changing
<Krinkle> yes
<MatmaRex> ugh.
<Krinkle> that's what we do for all values we cache that don't have
  timestamps.
<Krinkle> we do the same for the language globals in langdata module
<MatmaRex> sounds unpleasant, but alright
<MatmaRex> so we stick to adding the logo to ResourceLoaderSiteModule?
<Krinkle> and definition timestamp, and git version hash, etc. there
  is no other way to calculate it without lots of spurious invalidations
  (e.g. you'd need an array of all files that can possibly affect this
  global, and then some, and hte max() of their files, which is terrible
  and doesn't even always work with git and wmf-config)
<Krinkle> MatmaRex: Yep
<MatmaRex> Krinkle: while we're at it, let's change "#p-logo a" to
  ".mw-logo", hm?
<MatmaRex> .mw-wiki-logo, rather
<Krinkle> MatmaRex: Be sure to document that this means we will now
  always add a request for modules=site&only=styles on every page, where
  previously this only happened on wikis that enabled sitejs/css and
  actually created 1 or more wiki pages
<Krinkle> MatmaRex: Sounds good
<MatmaRex> document where?
<Krinkle> MatmaRex: Commit message
<Krinkle> MatmaRex: Also, given the above, this will now depend on
  https://gerrit.wikimedia.org/r/#/c/95463/
<MatmaRex> ah, duh. sure
<MatmaRex> hmm?
<Krinkle> MatmaRex: If not, you need to change OutputPage to take
  these new factors into account, but probably easier to make it
  dependent on https://gerrit.wikimedia.org/r/#/c/95463/
<MatmaRex> why would it? it seemed to work when i tested very biriefly
<Krinkle> because we need to load site module unconditionally
<Krinkle> MatmaRex: Delete your local site js/css pages
<Krinkle> and try again :)
<MatmaRex> i have none. it loaded the site module when i changed
  isKnownEmpty to return false, i think
<Krinkle> MatmaRex: OK, in addition, disable the wg variarbles that
  enable it.
<Krinkle> They are false on a new wiki by default.
<MatmaRex> i'mmm pretty sure they're true by default
<MatmaRex> wgUseSiteJs / Css?
<MatmaRex> or something
<MatmaRex> ok anyway, will have to check this
<Krinkle> MatmaRex: okay, they weren' always true by default.
  Whatever, the point is, OutputPage has some harccoded logic beyond
  isKnownEmpty that will break your change if you don't fix it.
<MatmaRex> got it, thanks
<Krinkle> Which is ugly, and why I remove it with
  https://gerrit.wikimedia.org/r/#/c/95463/
Comment 11 Gerrit Notification Bot 2013-12-02 23:15:21 UTC
Change 98460 abandoned by Tholam:
Create ResourceLoaderLogoModule to load logo

https://gerrit.wikimedia.org/r/98460
Comment 12 Quim Gil 2013-12-04 16:52:34 UTC
Question: will this solve the problem of MediaWiki links published in Facebook or Google+  featuring the "Powered by MediaWiki" image at the footer (in pages without images added by editors) because these services can't find any other image in the page?

If this bugfix would make those services show the logo of the MediaWiki instance by default, this would be a great collateral effect. If not, then I might file a new enhancement request.
Comment 13 Bartosz Dziewoński 2013-12-04 17:16:50 UTC
No, it won't; that would (to my understanding) require inlining the logo URL in the HTML output, but in a different way, or coming up with some magical solutions. That's already filed as bug 30113.
Comment 14 Gerrit Notification Bot 2014-09-22 18:11:27 UTC
Change 162000 had a related patch set uploaded by Krinkle:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/162000
Comment 15 Gerrit Notification Bot 2014-09-22 18:11:33 UTC
Change 162001 had a related patch set uploaded by Krinkle:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/162001
Comment 16 Gerrit Notification Bot 2014-09-22 21:57:23 UTC
Change 98356 merged by jenkins-bot:
Set site logo url in ResourceLoaderSiteModule instead of inline styles

https://gerrit.wikimedia.org/r/98356
Comment 17 Gerrit Notification Bot 2014-09-22 21:57:28 UTC
Change 162000 merged by jenkins-bot:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/162000
Comment 18 Florian 2014-09-25 21:32:08 UTC
Patches reverted in:
https://gerrit.wikimedia.org/r/#/c/163020/
and
https://gerrit.wikimedia.org/r/#/c/163023/

because of Bug 71334.

-> back to new
Comment 19 Kunal Mehta (Legoktm) 2014-09-25 21:33:35 UTC
The patch needs to use a separate RL module rather than being included in the site module.
Comment 20 Bartosz Dziewoński 2014-09-25 22:01:50 UTC
Just for the record, I am questioning my initial reasoning for this. My current opinion is that logo should just use <img src=$wgLogo alt=$wgSitename />, and who cares about caching forever.
Comment 21 Gerrit Notification Bot 2014-09-25 22:20:26 UTC
Change 163043 had a related patch set uploaded by Krinkle:
Set site logo in mediawiki.skinning.interface module instead of inline styles

https://gerrit.wikimedia.org/r/163043
Comment 22 Gerrit Notification Bot 2014-09-26 21:16:21 UTC
Change 163043 merged by jenkins-bot:
Set site logo in mediawiki.skinning.interface module instead of inline styles

https://gerrit.wikimedia.org/r/163043
Comment 23 Gerrit Notification Bot 2014-09-26 22:03:13 UTC
Change 163291 had a related patch set uploaded by Krinkle:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/163291
Comment 24 Gerrit Notification Bot 2014-09-26 22:09:27 UTC
Change 162001 merged by jenkins-bot:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/162001
Comment 25 Gerrit Notification Bot 2014-09-26 22:09:41 UTC
Change 163291 merged by jenkins-bot:
Use mw-wiki-logo class instead of inline background-image

https://gerrit.wikimedia.org/r/163291
Comment 26 Kunal Mehta (Legoktm) 2014-09-26 22:38:27 UTC
Re-merged into core, and patched for the tarball skins that display a logo (MonoBook and Vector).

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


Navigation
Links