r87145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87144‎ | r87145 | r87146 >
Date:22:40, 29 April 2011
Author:demon
Status:reverted (Comments)
Tags:
Comment:
(bug 28752) XCache doesn't work in CLI mode
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/objectcache/XCacheBagOStuff.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/objectcache/XCacheBagOStuff.php
@@ -8,12 +8,27 @@
99 */
1010 class XCacheBagOStuff extends BagOStuff {
1111 /**
 12+ * Are we operating in CLI mode? Since xcache doesn't work then and they
 13+ * don't want to change that
 14+ * @see bug 28752
 15+ * @var bool
 16+ */
 17+ private $isCli = false;
 18+
 19+ public function __construct() {
 20+ $this->isCli = php_sapi_name() == 'cli';
 21+ }
 22+
 23+ /**
1224 * Get a value from the XCache object cache
1325 *
1426 * @param $key String: cache key
1527 * @return mixed
1628 */
1729 public function get( $key ) {
 30+ if( $this->isCli ) {
 31+ return false;
 32+ }
1833 $val = xcache_get( $key );
1934
2035 if ( is_string( $val ) ) {
@@ -32,8 +47,9 @@
3348 * @return bool
3449 */
3550 public function set( $key, $value, $expire = 0 ) {
36 - xcache_set( $key, serialize( $value ), $expire );
37 -
 51+ if( !$this->isCli ) {
 52+ xcache_set( $key, serialize( $value ), $expire );
 53+ }
3854 return true;
3955 }
4056
@@ -45,8 +61,9 @@
4662 * @return bool
4763 */
4864 public function delete( $key, $time = 0 ) {
49 - xcache_unset( $key );
50 -
 65+ if( !$this->isCli ) {
 66+ xcache_unset( $key );
 67+ }
5168 return true;
5269 }
5370 }
Index: trunk/phase3/RELEASE-NOTES
@@ -255,6 +255,7 @@
256256 left-to-right.
257257 * (bug 28719) Do not call mLinkHolders __destruct explicitly
258258 * (bug 21196) Article::getContributors() no longer fail on PostgreSQL.
 259+* (bug 28752) XCache doesn't work in CLI mode.
259260
260261 === API changes in 1.18 ===
261262 * (bug 26339) Throw warning when truncating an overlarge API result.

Follow-up revisions

RevisionCommit summaryAuthorDate
r89713Revert r87145, bug 28752: Xcache doesn't work in cli mode. As pointed out on ...demon00:53, 8 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   10:09, 30 April 2011

There is much bigger problem if it doesn't work in CLI. Some maintenance scripts like resetPassword will not function properly. Should we highly discourage its use or perhaps even not support it?

Also the release notes is misleading. XCache will not work in CLI after this fix either.

#Comment by Bryan (talk | contribs)   18:34, 30 April 2011

Can you check if this breaks parser tests? If I recall correctly, when using wincache, having BagOStuff::get() returning false caused parser tests to fail.

#Comment by 😂 (talk | contribs)   21:30, 1 May 2011

Shouldn't parser tests run with all caching disabled anyway?

#Comment by Hashar (talk | contribs)   20:53, 5 June 2011

Bryan, ^demon , can you sort this revision out and have it marked 'ok' ? :-) Thanks!

#Comment by Brion VIBBER (talk | contribs)   00:34, 8 June 2011

This doesn't seem to fix the issue that xcache doesn't work in CLI mode; it just seems to ... avoid using it?

Being unable to overwrite items in cache from background & maintenance operations in command-line scripts means that your cache can become inconsistent, so this just hides problems rather than fixing them.

Status & tagging log