Manual:Disabling file lock manager

From MediaWiki.org
Jump to: navigation, search

In some setups, when uploading a file, an error appears stating Could not acquire lock for "mwstore://local-backend/local-public/...". This error is usually caused by an incorrect configuration of $wgUploadDirectory, by a lack of permissions to write on that directory, or a SELinux or suPHP misconfiguration. In such cases, disabling the lock file manager will prevent the Could not acquire lock error, but you will get another error when the file is actually saved.

In cases where the lock manager is the problem (maybe a filesystem that has some issues with it) there's a way to override the current filesystem lock manager with a null lock manager.

You can do that by putting this code in LocalSettings.php:

// Create a local backend with a null lock manager
$wgFileBackends[] = array(
        'name'        => 'local-backend',
        'class'       => 'FSFileBackend',
        'lockManager' => 'nullLockManager',
        'containerPaths' => array(
                'local-public'  => "{$wgUploadDirectory}",
                'local-thumb'   => "{$wgUploadDirectory}/thumb",
                'local-transcoded' => "{$wgUploadDirectory}/transcoded",
                'local-deleted' => $wgDeletedDirectory,
                'local-temp'    => "{$wgUploadDirectory}/temp",
        ),
        'fileMode'    => 0644,
);

// Define a standard file repository that uses the local backend defined before
$wgLocalFileRepo = array (
        'class'             => 'LocalRepo',
        'name'              => 'local',
        'directory'         => $wgUploadDirectory,
        'scriptDirUrl'      => $wgScriptPath,
        'scriptExtension'   => $wgScriptExtension,
        'url'               => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
        'hashLevels'        => $wgHashedUploadDirectory ? 2 : 0,
        'thumbScriptUrl'    => $wgThumbnailScriptPath,
        'transformVia404'   => !$wgGenerateThumbnailOnParse,
        'deletedDir'        => $wgDeletedDirectory,
        'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0,
        'backend'           => 'local-backend',
);