r63707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63706‎ | r63707 | r63708 >
Date:20:46, 13 March 2010
Author:happy-melon
Status:ok
Tags:
Comment:
Add $wgAllowUserCssPrefs option to disable CSS-based preferences. These are injected by a 'stylesheet' /w/index.php?title=-&action=raw&gen=css, which is ~20 times slower to get out to the browser than a normal stylesheet. If you don't care about your users too much, getting rid of these options can dramatically improve page load times.

Also, update monobook/main.css to actually offer the redlink colour that's been seen on wikipedia since forever. It's only when you turn off this per-user styling stuff that you realise that it's been overriding a different colour since September 2004 :D
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/monobook/main.css
@@ -86,7 +86,7 @@
8787 color: #772233;
8888 }
8989 a.new, #p-personal a.new {
90 - color: #ba0000;
 90+ color: #cc2200;
9191 }
9292 a.new:visited, #p-personal a.new:visited {
9393 color: #a55858;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2905,6 +2905,13 @@
29062906 */
29072907 $wgAllowUserCss = false;
29082908
 2909+/**
 2910+ * Allow user-preferences implemented in CSS?
 2911+ * This allows users to customise the site appearance to a greater
 2912+ * degree; disabling it will improve page load times.
 2913+ */
 2914+$wgAllowUserCssPrefs = true;
 2915+
29092916 /** Use the site's Javascript page? */
29102917 $wgUseSiteJs = true;
29112918
Index: trunk/phase3/includes/Preferences.php
@@ -593,17 +593,20 @@
594594
595595 static function renderingPreferences( $user, &$defaultPreferences ) {
596596 ## Page Rendering ##############################
597 - $defaultPreferences['underline'] =
598 - array(
599 - 'type' => 'select',
600 - 'options' => array(
601 - wfMsg( 'underline-never' ) => 0,
602 - wfMsg( 'underline-always' ) => 1,
603 - wfMsg( 'underline-default' ) => 2,
604 - ),
605 - 'label-message' => 'tog-underline',
606 - 'section' => 'rendering/advancedrendering',
607 - );
 597+ global $wgAllowUserCssPrefs;
 598+ if( $wgAllowUserCssPrefs ){
 599+ $defaultPreferences['underline'] =
 600+ array(
 601+ 'type' => 'select',
 602+ 'options' => array(
 603+ wfMsg( 'underline-never' ) => 0,
 604+ wfMsg( 'underline-always' ) => 1,
 605+ wfMsg( 'underline-default' ) => 2,
 606+ ),
 607+ 'label-message' => 'tog-underline',
 608+ 'section' => 'rendering/advancedrendering',
 609+ );
 610+ }
608611
609612 $stubThresholdValues = array( 0, 50, 100, 500, 1000, 2000, 5000, 10000 );
610613 $stubThresholdOptions = array();
@@ -619,18 +622,20 @@
620623 'size' => 20,
621624 'label' => wfMsg( 'stub-threshold' ), // Raw HTML message. Yay?
622625 );
623 - $defaultPreferences['highlightbroken'] =
624 - array(
625 - 'type' => 'toggle',
626 - 'section' => 'rendering/advancedrendering',
627 - 'label' => wfMsg( 'tog-highlightbroken' ), // Raw HTML
628 - );
629 - $defaultPreferences['showtoc'] =
630 - array(
631 - 'type' => 'toggle',
632 - 'section' => 'rendering/advancedrendering',
633 - 'label-message' => 'tog-showtoc',
634 - );
 626+ if( $wgAllowUserCssPrefs ){
 627+ $defaultPreferences['highlightbroken'] =
 628+ array(
 629+ 'type' => 'toggle',
 630+ 'section' => 'rendering/advancedrendering',
 631+ 'label' => wfMsg( 'tog-highlightbroken' ), // Raw HTML
 632+ );
 633+ $defaultPreferences['showtoc'] =
 634+ array(
 635+ 'type' => 'toggle',
 636+ 'section' => 'rendering/advancedrendering',
 637+ 'label-message' => 'tog-showtoc',
 638+ );
 639+ }
635640 $defaultPreferences['nocache'] =
636641 array(
637642 'type' => 'toggle',
@@ -649,12 +654,14 @@
650655 'section' => 'rendering/advancedrendering',
651656 'label-message' => 'tog-showjumplinks',
652657 );
653 - $defaultPreferences['justify'] =
654 - array(
655 - 'type' => 'toggle',
656 - 'section' => 'rendering/advancedrendering',
657 - 'label-message' => 'tog-justify',
658 - );
 658+ if( $wgAllowUserCssPrefs ){
 659+ $defaultPreferences['justify'] =
 660+ array(
 661+ 'type' => 'toggle',
 662+ 'section' => 'rendering/advancedrendering',
 663+ 'label-message' => 'tog-justify',
 664+ );
 665+ }
659666 $defaultPreferences['numberheadings'] =
660667 array(
661668 'type' => 'toggle',
@@ -664,7 +671,7 @@
665672 }
666673
667674 static function editingPreferences( $user, &$defaultPreferences ) {
668 - global $wgUseExternalEditor, $wgLivePreview;
 675+ global $wgUseExternalEditor, $wgLivePreview, $wgAllowUserCssPrefs;
669676
670677 ## Editing #####################################
671678 $defaultPreferences['cols'] =
@@ -683,19 +690,20 @@
684691 'min' => 4,
685692 'max' => 1000,
686693 );
687 -
688 - $defaultPreferences['editfont'] =
689 - array(
690 - 'type' => 'select',
691 - 'section' => 'editing/advancedediting',
692 - 'label-message' => 'editfont-style',
693 - 'options' => array(
694 - wfMsg( 'editfont-default' ) => 'default',
695 - wfMsg( 'editfont-monospace' ) => 'monospace',
696 - wfMsg( 'editfont-sansserif' ) => 'sans-serif',
697 - wfMsg( 'editfont-serif' ) => 'serif',
698 - )
699 - );
 694+ if( $wgAllowUserCssPrefs ){
 695+ $defaultPreferences['editfont'] =
 696+ array(
 697+ 'type' => 'select',
 698+ 'section' => 'editing/advancedediting',
 699+ 'label-message' => 'editfont-style',
 700+ 'options' => array(
 701+ wfMsg( 'editfont-default' ) => 'default',
 702+ wfMsg( 'editfont-monospace' ) => 'monospace',
 703+ wfMsg( 'editfont-sansserif' ) => 'sans-serif',
 704+ wfMsg( 'editfont-serif' ) => 'serif',
 705+ )
 706+ );
 707+ }
700708 $defaultPreferences['previewontop'] =
701709 array(
702710 'type' => 'toggle',
@@ -708,12 +716,14 @@
709717 'section' => 'editing/advancedediting',
710718 'label-message' => 'tog-previewonfirst',
711719 );
712 - $defaultPreferences['editsection'] =
713 - array(
714 - 'type' => 'toggle',
715 - 'section' => 'editing/advancedediting',
716 - 'label-message' => 'tog-editsection',
717 - );
 720+ if( $wgAllowUserCssPrefs ){
 721+ $defaultPreferences['editsection'] =
 722+ array(
 723+ 'type' => 'toggle',
 724+ 'section' => 'editing/advancedediting',
 725+ 'label-message' => 'tog-editsection',
 726+ );
 727+ }
718728 $defaultPreferences['editsectiononrightclick'] =
719729 array(
720730 'type' => 'toggle',
@@ -1116,7 +1126,7 @@
11171127 $ret = array();
11181128
11191129 foreach ( $wgImageLimits as $index => $limits ) {
1120 - $display = "{$limits[0]}×{$limits[1]}" . wfMsg( 'unit-pixel' );
 1130+ $display = "{$limits[0]}×{$limits[1]}" . wfMsg( 'unit-pixel' );
11211131 $ret[$display] = $index;
11221132 }
11231133
Index: trunk/phase3/includes/Skin.php
@@ -548,6 +548,7 @@
549549
550550 /**
551551 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
 552+ * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
552553 */
553554 protected function reallyGenerateUserStylesheet() {
554555 global $wgUser;
@@ -629,18 +630,21 @@
630631 $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
631632 }
632633
633 - if( $wgUser->isLoggedIn() ) {
634 - // Ensure that logged-in users' generated CSS isn't clobbered
635 - // by anons' publicly cacheable generated CSS.
636 - $siteargs['smaxage'] = '0';
637 - $siteargs['ts'] = $wgUser->mTouched;
 634+ global $wgAllowUserCssPrefs;
 635+ if( $wgAllowUserCssPrefs ){
 636+ if( $wgUser->isLoggedIn() ) {
 637+ // Ensure that logged-in users' generated CSS isn't clobbered
 638+ // by anons' publicly cacheable generated CSS.
 639+ $siteargs['smaxage'] = '0';
 640+ $siteargs['ts'] = $wgUser->mTouched;
 641+ }
 642+ // Per-user styles based on preferences
 643+ $siteargs['gen'] = 'css';
 644+ if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
 645+ $siteargs['useskin'] = $us;
 646+ }
 647+ $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
638648 }
639 - // Per-user styles based on preferences
640 - $siteargs['gen'] = 'css';
641 - if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
642 - $siteargs['useskin'] = $us;
643 - }
644 - $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
645649
646650 // Per-user custom style pages
647651 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -30,6 +30,8 @@
3131 the names of the individual files within the gallery
3232 * (bug 12797) Add $wgGalleryOptions for adjusting of default gallery display
3333 options
 34+* $wgAllowUserCssPrefs option allows disabling CSS-based preferences; which can
 35+ improve page loading speed.
3436
3537 === Bug fixes in 1.17 ===
3638 * (bug 17560) Half-broken deletion moved image files to deletion archive without

Follow-up revisions

RevisionCommit summaryAuthorDate
r63708Fix encoding broken in r63707happy-melon20:49, 13 March 2010
r66608Follow up r63707: update the default link colour in all skins to match what's...happy-melon13:01, 18 May 2010

Status & tagging log