Last modified: 2009-11-20 15:38:13 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 T23403, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 21403 - memcached class conflicts with PHP's memcached extension
memcached class conflicts with PHP's memcached extension
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.16.x
PC Linux
: Normal major (vote)
: ---
Assigned To: Nobody - You can work on this!
http://aerospace.ulsan.ac.kr/cim/wiki
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-04 03:08 UTC by Hyun-Joon, Kim
Modified: 2009-11-20 15:38 UTC (History)
2 users (show)

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


Attachments
some edits to avoid conflicting PHP-memcached extension (2.20 KB, patch)
2009-11-05 04:18 UTC, Hyun-Joon, Kim
Details
including patched memcached-client.php patch (651 bytes, patch)
2009-11-05 04:20 UTC, Hyun-Joon, Kim
Details

Description Hyun-Joon, Kim 2009-11-04 03:08:24 UTC
I upgraded wikimedia from 1.15 to 1.16-svn and tested brand new vector skin. it looks well/

in LocalSettings.php, I assigned cache type to CACHE_MEMCACHED. and after that PHP does not operates.
In apache log, the message is

------
PHP Warning:  Memcached::__construct() expects parameter 1 to be string, array given in /usr/share/mediawiki/includes/ObjectCache.php on line 63, referer: <url>

PHP Fatal error:  Call to a member function set_servers() on a non-object in /usr/share/mediawiki/includes/ObjectCache.php on line 64, referer: <url>
--------

memcached version 1.4.2, and PHP-memcached was built into PHP as static library. The PHP-memcached version is 1.0, which was built against libmemcached 0.3.0. PHP version is 5.2.11.
Comment 1 Roan Kattouw 2009-11-04 08:51:26 UTC
Are you sure you configured stuff correctly? See http://www.mediawiki.org/wiki/Memcached#Setup
Comment 2 Alexandre Emsenhuber [IAlex] 2009-11-04 11:25:01 UTC
It seems that there is a conflict between PHP's memcached extension (http://www.php.net/manual/en/book.memcached.php) and our memcached class (includes/memcached-client.php).
Comment 3 Hyun-Joon, Kim 2009-11-04 13:36:07 UTC
(In reply to comment #1)
> Are you sure you configured stuff correctly? See
> http://www.mediawiki.org/wiki/Memcached#Setup
> 

Yes, I configured memcached daemon as a background service. My server Linux distro is Fedora Core 11(FC11),
At First I thought that the version of memcached and PHP-memcached is old, so I downloaded recent version source tarballs from developers website. and I compiled and installed to my server. But still it does not work.

In LocalSettings.php, all settings about memcacehd is correct, I thought. But maybe still error? :) I copied my LocalSettings.php's memcached section to it

----------
## Shared memory settings
$wgMainCacheType = CACHE_MEMCACHED;
$wgParserCacheType = CACHE_MEMCACHED; # optional
$wgMessageCacheType = CACHE_MEMCACHED; # optional
$wgMemCachedServers = array("localhost:11211");
$wgUseFileCache = true;
$wgSessionsInMemcached = true; # optional
$wgMemCachedPersistent = true;
$wgFileCacheDirectory = '/tmp/wikicache';
$wgCacheDirectory = '/tmp/wikicache';
$wgUseMemCached = true;
----------

Still error in my configuration? If so, tell me about some tips and how-tos to me, please.

Thanks Roan.
I use file cache also. and I turned off MEMCACHED support by usgin CACHE_ANYTHING.
Comment 4 Hyun-Joon, Kim 2009-11-04 13:50:18 UTC
(In reply to comment #2)
> It seems that there is a conflict between PHP's memcached extension
> (http://www.php.net/manual/en/book.memcached.php) and our memcached class
> (includes/memcached-client.php).
> 

Yes, I saw PHP manual about memcached extensions, and the memcached:__construct() accepts a single string variable. But MediaWiki's Cache routine is not.

Line from 53 to 67 in includes/ObjectCache.php

----
53	if ( $type == CACHE_MEMCACHED ) {
54		if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ) {
55			if ( !class_exists( 'MemCachedClientforWiki' ) ) {
56		class MemCachedClientforWiki extends memcached {
57					function _debugprint( $text ) {
58						wfDebug( "memcached: $text" );
59					}
60				}
61			}
62			$wgCaches[CACHE_MEMCACHED] = new MemCachedClientforWiki(
63				array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) );
64			$wgCaches[CACHE_MEMCACHED]->set_servers( $wgMemCachedServers );
65			$wgCaches[CACHE_MEMCACHED]->set_debug( $wgMemCachedDebug );
66		}
67		$cache =& $wgCaches[CACHE_MEMCACHED];
------

At line 62-63, the codes is contructing memcache persistence connection. But the argument is array, not string. I think that if the argument is not string, PHP can not parse codes, even if all array's elements are string.

Do you have any solution to it? I edited some codes for fixing, but still not work. My PHP is poor... :(..

Thanks for reading and review my bug,  Alexandre.
Comment 5 Hyun-Joon, Kim 2009-11-05 04:18:40 UTC
Created attachment 6752 [details]
some edits to avoid conflicting PHP-memcached extension

if PHP-memcached extension installed and activated, MediaWiki's the class memcached in memcached-client.php is conflicts with PHP-memcached extension.

It's because memcache-dclient class use same name class, and does not overrides PHP-memcached class. So, I renamed class name to mwMemcached.

It works well. And at top of  ObjectCache.php, just add this line

require_once('ObjectCache.php');

and edit ObjectCache.php with other patch that I attached.

I hope this will help~ :)
Comment 6 Hyun-Joon, Kim 2009-11-05 04:20:46 UTC
Created attachment 6753 [details]
including patched memcached-client.php patch

After patching memcached-client.php, patch ObjectCache.php to use edited memcached-client class 'mwMemcached'.

It's so simple, and works well with memcached daemon.

I hope this will help~ :)
Comment 7 Hyun-Joon, Kim 2009-11-05 04:24:09 UTC
oops! in comment #5 with memcached-client.php patch, there's mistake.

correct mistake.

require_once('ObjectCache.php');

-> require_once('memcached-client.php');

please see and review my patch.
I think it doesn't have any license problem. isn't it?
Comment 8 Alexandre Emsenhuber [IAlex] 2009-11-20 15:38:13 UTC
Fixed in r59289.

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


Navigation
Links