Page MenuHomePhabricator

$wgShowIPinHeader does not work for 1.27
Closed, InvalidPublic

Description

When running 1.27 alpha (currently 0158312d4bc3de9c15064a12a73b4bf57580e45e) I always get "Create account" and "Log in" with pretty standard LocalSettings.php and also when setting $wgShowIPinHeader = true explicitly.

Having applied the following patch:

`diff
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index 12ebb54..6850f6a 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -730,7 +730,10 @@ abstract class Skin extends ContextSource {
 	 */
 	function showIPinHeader() {
 		global $wgShowIPinHeader;
-		return $wgShowIPinHeader && session_id() != '';
+		wfDebugLog( __METHOD__, '$wgShowIPinHeader is ' . var_export( $wgShowIPinHeader, true ) );
+		$what = $wgShowIPinHeader && session_id() != '';
+		wfDebugLog( __METHOD__, "but returning " . var_export( $what, true ) );
+		return $what;
 	}
 
 	/**
`

I can see in the debug log the following when asking for http://tools.wikimedia.pl/~saper/y/index.php?title=Main_Page&action=edit

`
[Skin::showIPinHeader] $wgShowIPinHeader is true
[Skin::showIPinHeader] but returning false
[Skin::showIPinHeader] $wgShowIPinHeader is true
[Skin::showIPinHeader] but returning false
[Skin::showIPinHeader] $wgShowIPinHeader is true
[Skin::showIPinHeader] but returning false
`

Event Timeline

saper raised the priority of this task from to Needs Triage.
saper updated the task description. (Show Details)
saper added a project: MediaWiki-Interface.
saper added a subscriber: saper.

Running PHP Version 5.6.9-pl0-gentoo as an apache2 module, made sure I have session.auto_start set to Off

Debug log for the request

1Start request GET /~saper/y/index.php?title=Main_Page&action=edit
2HTTP HEADERS:
3HOST: tools.wikimedia.pl
4USER-AGENT: Mozilla/5.0 (X11; Linux x86-64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36
5ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
6ACCEPT-LANGUAGE: en-US,en;q=0.5
7ACCEPT-ENCODING: gzip, deflate
8DNT: 1
9CONNECTION: close
10[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
11[caches] LocalisationCache: using store LCStoreDB
12Fully initialised
13Connected to database 0 at localhost
14Title::getRestrictionTypes: applicable restrictions to [[Main Page]] are {edit,move}
15[ContentHandler] Created handler for wikitext: WikitextContentHandler
16EditPage::edit: enter
17EditPage::importFormData: Not a posted form.
18IP: 2a01:198:200:15f::2
19User::getBlockedStatus: checking...
20Connected to database 0 at localhost
21[DBPerformance] [GET] Expectation (masterConns <= 0) by MediaWiki::main not met:
22[connect to (finaltest)]
23TransactionProfiler.php line 307 calls wfBacktrace()
24TransactionProfiler.php line 146 calls TransactionProfiler->reportExpectationViolated()
25LoadBalancer.php line 556 calls TransactionProfiler->recordConnection()
26SqlBagOStuff.php line 165 calls LoadBalancer->getConnection()
27SqlBagOStuff.php line 245 calls SqlBagOStuff->getDB()
28SqlBagOStuff.php line 223 calls SqlBagOStuff->getMulti()
29SqlBagOStuff.php line 219 calls SqlBagOStuff->getWithToken()
30BagOStuff.php line 146 calls SqlBagOStuff->doGet()
31MessageCache.php line 287 calls BagOStuff->get()
32MessageCache.php line 907 calls MessageCache->load()
33MessageCache.php line 826 calls MessageCache->getMsgFromNamespace()
34MessageCache.php line 764 calls MessageCache->getMessageFromFallbackChain()
35Message.php line 1146 calls MessageCache->get()
36Message.php line 769 calls Message->fetchMessage()
37Message.php line 860 calls Message->toString()
38OutputPage.php line 994 calls Message->text()
39EditPage.php line 2233 calls OutputPage->setPageTitle()
40EditPage.php line 2458 calls EditPage->setHeaders()
41EditPage.php line 596 calls EditPage->showEditForm()
42EditAction.php line 58 calls EditPage->edit()
43MediaWiki.php line 457 calls EditAction->show()
44MediaWiki.php line 254 calls MediaWiki->performAction()
45MediaWiki.php line 669 calls MediaWiki->performRequest()
46MediaWiki.php line 474 calls MediaWiki->main()
47index.php line 41 calls MediaWiki->run()
48
49[SQLBagOStuff] Connection 197628 will be used for SqlBagOStuff
50[DBPerformance] [GET] Expectation (writes <= 0) by MediaWiki::main not met:
51query-m: REPLACE INTO `objectcache` (keyname,value,exptime) VALUES ('X')
52TransactionProfiler.php line 307 calls wfBacktrace()
53TransactionProfiler.php line 200 calls TransactionProfiler->reportExpectationViolated()
54Database.php line 999 calls TransactionProfiler->recordQueryCompletion()
55Database.php line 2753 calls DatabaseBase->query()
56DatabaseMysqlBase.php line 455 calls DatabaseBase->nativeReplace()
57SqlBagOStuff.php line 338 calls DatabaseMysqlBase->replace()
58SqlBagOStuff.php line 352 calls SqlBagOStuff->setMulti()
59BagOStuff.php line 469 calls SqlBagOStuff->set()
60BagOStuff.php line 326 calls BagOStuff->add()
61BagOStuff.php line 393 calls BagOStuff->lock()
62MessageCache.php line 688 calls BagOStuff->getScopedLock()
63MessageCache.php line 386 calls MessageCache->getReentrantScopedLock()
64MessageCache.php line 315 calls MessageCache->loadFromDBWithLock()
65MessageCache.php line 907 calls MessageCache->load()
66MessageCache.php line 826 calls MessageCache->getMsgFromNamespace()
67MessageCache.php line 764 calls MessageCache->getMessageFromFallbackChain()
68Message.php line 1146 calls MessageCache->get()
69Message.php line 769 calls Message->fetchMessage()
70Message.php line 860 calls Message->toString()
71OutputPage.php line 994 calls Message->text()
72EditPage.php line 2233 calls OutputPage->setPageTitle()
73EditPage.php line 2458 calls EditPage->setHeaders()
74EditPage.php line 596 calls EditPage->showEditForm()
75EditAction.php line 58 calls EditPage->edit()
76MediaWiki.php line 457 calls EditAction->show()
77MediaWiki.php line 254 calls MediaWiki->performAction()
78MediaWiki.php line 669 calls MediaWiki->performRequest()
79MediaWiki.php line 474 calls MediaWiki->main()
80index.php line 41 calls MediaWiki->run()
81
82[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database
83Unstubbing $wgParser on call of $wgParser::firstCallInit from MessageCache->getParser
84Parser: using preprocessor: Preprocessor_DOM
85Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions->__construct
86Title::getRestrictionTypes: applicable restrictions to [[Main Page]] are {edit,move}
87[GlobalTitleFail] MessageCache::parse called by EditPage->showEditForm/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
88Title::getRestrictionTypes: applicable restrictions to [[Main Page]] are {edit,move}
89[GlobalTitleFail] MessageCache::parse called by EditPage->showSummaryInput/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
90[GlobalTitleFail] MessageCache::parse called by EditPage->getCheckboxes/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
91[GlobalTitleFail] MessageCache::parse called by EditPage->getCheckboxes/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
92[GlobalTitleFail] MessageCache::parse called by EditPage->getCancelLink/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
93[GlobalTitleFail] MessageCache::parse called by EditPage->showStandardInputs/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
94[GlobalTitleFail] MessageCache::parse called by EditPage->showEditTools/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set.
95MediaWiki::doPreOutputCommit completed; all transactions committed
96[Skin::showIPinHeader] $wgShowIPinHeader is true
97[Skin::showIPinHeader] but returning false
98[Skin::showIPinHeader] $wgShowIPinHeader is true
99[Skin::showIPinHeader] but returning false
100[Skin::showIPinHeader] $wgShowIPinHeader is true
101[Skin::showIPinHeader] but returning false
102Title::getRestrictionTypes: applicable restrictions to [[Main Page]] are {edit,move}
103OutputPage::sendCacheControl: private caching; **
104LoadBalancer::reuseConnection: this connection was not opened as a foreign connection
105Request ended normally
106[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
107[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
108[caches] LocalisationCache: using store LCStoreDB
109[caches] LocalisationCache: using store LCStoreDB
110[SQLBagOStuff] Connection 197631 will be used for SqlBagOStuff
111[SQLBagOStuff] Connection 197632 will be used for SqlBagOStuff
112[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database
113[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
114[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
115[caches] LocalisationCache: using store LCStoreDB
116[caches] LocalisationCache: using store LCStoreDB
117[SQLBagOStuff] Connection 197635 will be used for SqlBagOStuff
118[SQLBagOStuff] Connection 197636 will be used for SqlBagOStuff
119[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database, could not acquire main lock, using stale cache
120[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database
121[ContentHandler] Created handler for javascript: JavaScriptContentHandler
122[ContentHandler] Created handler for css: CssContentHandler
123Start request GET /~saper/y/api.php?action=query&list=embeddedin&eititle=Template:Stub
124HTTP HEADERS:
125HOST: tools.wikimedia.pl
126CONNECTION: Keep-alive
127ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
128FROM: googlebot(at)googlebot.com
129ACCEPT-ENCODING: gzip,deflate
130USER-AGENT: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
131[caches] main: EmptyBagOStuff, message: SqlBagOStuff, parser: SqlBagOStuff
132[caches] LocalisationCache: using store LCStoreDB
133Fully initialised
134Connected to database 0 at localhost
135ApiMain::setCacheMode: downgrading cache mode 'public' to 'anon-public-user-private' due to uselang=user
136ApiMain::setCacheMode: setting cache mode anon-public-user-private
137Connected to database 0 at localhost
138[SQLBagOStuff] Connection 197643 will be used for SqlBagOStuff
139IP: 66.249.67.231
140[MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database
141Unstubbing $wgParser on call of $wgParser::firstCallInit from MessageCache->getParser
142Parser: using preprocessor: Preprocessor_DOM
143Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions->__construct
144[Skin::showIPinHeader] $wgShowIPinHeader is true
145[Skin::showIPinHeader] but returning false
146[Skin::showIPinHeader] $wgShowIPinHeader is true
147[Skin::showIPinHeader] but returning false
148OutputPage::sendCacheControl: private caching; **
149Request ended normally

I wonder why is this pretty ancient check for session_id() there?

This was added in 2007: https://www.mediawiki.org/wiki/Special:Code/MediaWiki/19795

Aklapper triaged this task as Medium priority.Oct 22 2015, 5:36 PM
Aklapper added a project: MW-1.27-release.
Aklapper set Security to None.
saper claimed this task.

Things I learned today: new PHP session gets opened only after visiting Special:Userlogin and after this only the IP address appears at the top. Checked with 1.18, 1.20 and the master. Probably we should not turn off HTML caching on $wgShowIPinHeader only.

Sorry for noise!

Note to self: one could add:

diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php
index 483eaa5..3346ea3 100644
--- a/includes/cache/HTMLFileCache.php
+++ b/includes/cache/HTMLFileCache.php
@@ -100,7 +100,7 @@ class HTMLFileCache extends FileCacheBase {
 		if ( !$wgUseFileCache ) {
 			return false;
 		}
-		if ( $wgShowIPinHeader || $wgDebugToolbar ) {
+		if ( $context->getSkin()->showIPinHeader() || $wgDebugToolbar ) {
 			wfDebug( "HTML file cache skipped. Either \$wgShowIPinHeader and/or \$wgDebugToolbar on\n" );
 
 			return false;

but Setup.php unsets $wgShowIPHeader and $wgDebugToolbar anyway.