PHP 5 safe_mode - MediaWiki (2024)

PHP 5 safe_mode - MediaWiki (1)Note: There is a parameter to index.php called safemode that is completely unrelated. See Help:Locating broken scripts for more about using that parameter.

PHP 5 safe_mode - MediaWiki (2)

This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on any information on this page.

PHP safe_mode was DEPRECATED as of PHP 5.3.0 and REMOVED on PHP 5.4.0

Safe mode criticism

PHP's safe_mode is an ill-conceived, broken-by-design setting in PHP that is supposed to make broken scripts safe. It was deprecated in PHP 5.3 and removed in PHP 5.4 (see the PHP documentation). MediaWiki can run with safe_mode enabled, but many of the advanced features will not work or need additional configuration.

To turn off safe mode, put this into your php.ini file:

 safe_mode = Off

If you cannot turn safe_mode off (such is the case with many shared webhosts), please consider finding a new host. If that is out of the question, read the next section for methods to enable some things with safe_mode on. It is recommended that if you do have access to php.ini, that you turn safe_mode off instead of using the methods described below.

Another opinion

Safe mode is really a bad solution. Default MediaWiki installs are generally safe and do not require safe_mode to be enabled, but if you are really paranoid, you still can set up full-featured wiki with some effort. However, you should not do this.

Making your wiki work in safe_mode

Image upload and deletion workaround

To make image uploads and deletions work in your wiki, you need to create the images/archive, images/temp, images/deleted, and images/thumb directories and make them all writable by your webserver (chmod 777). Then, set the following in your LocalSettings.php file:

$wgEnableUploads = true;$wgHashedUploadDirectory = false;$wgFileStore['deleted']['hash'] = 0;

Fixing errors with putenv() function

Sometimes you will see errors that putenv() can't work properly because of safe mode. It doesn't affect any functionality but looks rather bad for user.To remove errors, you can either comment lines in wiki source code (not recommended), or disable error reporting in PHP by setting the following at the top of your LocalSettings.php file

error_reporting(0); #Disable the reporting of errorsini_set('display_errors', false); #same as above, need more permissions, usually disabled function

Setting time zone in safe mode

In safe mode, things like

$wgLocaltimezone = "America/New_York";$oldtz = getenv("TZ");putenv("TZ=$wgLocaltimezone");

Won't work. Instead, you should use the following code (place it in your LocalSettings.php file)

$wgLocaltimezone = 'CET';$wgDefaultUserOptions['timecorrection'] = '04:00';//time offset +4, adjust accordingly to whatever timezone you wish

Maintenance scripts (creating sitemap, etc)

You won't be able to run maintenance mediawiki scripts in safe mode. But there are several workarounds. For example, even if you can't generate sitemap using shell scripts, you still can use specialized extension (for example, Extension:ManualSitemap‎).

Other issues

Thumbnails are the only thing which still shouldn't work in wiki after you changed everything above. There are several options for enabling thumbnails. For example, you can generate thumbnails on every client request, instead of generating and writing them to thumbs directory. To do it, place the following in LocalSettings.php

$wgThumbnailScriptPath = "{$wgScriptPath}/thumb.php";

If you want other solutions to this issue, please read the article linked to in the bottom of the page.

Fix for thumbnails

Upgrade file includes/filerepo/File.php, change:

function getThumbRel( $suffix = false ) {$path = 'thumb';// /' . $this->getRel(); //[JS] This fix it.if ( $suffix !== false ) {$path .= '/' . $suffix;}return $path;}

and

function getThumbUrl( $suffix = false ) {$path = $this->repo->getZoneUrl('public') . '/thumb'; // /' . $this->getUrlRel();//[JS] This fix URLsif ( $suffix !== false ) {$path .= '/' . rawurlencode( $suffix );}return $path;}

Make sure directories images and images/thumb are writable.

External links

  • Guide to getting your wiki work in safe_mode - Some of the methods described may not work in newer versions of MediaWiki and/or require hacks to the core files (which get lost during upgrades). Also there is a method with changing safe mod settings so that all wiki will work fine.
PHP 5 safe_mode - MediaWiki (2024)
Top Articles
Sticky Cranberry Gingerbread Recipe
Try This One-Pot Chicken and Dumplings Recipe When You Need a Comforting Dinner Fast
Custom Screensaver On The Non-touch Kindle 4
Nyu Paralegal Program
GAY (and stinky) DOGS [scat] by Entomb
You can put a price tag on the value of a personal finance education: $100,000
Phillies Espn Schedule
Conduent Connect Feps Login
Aspen.sprout Forum
Vcuapi
Lima Funeral Home Bristol Ri Obituaries
Sony E 18-200mm F3.5-6.3 OSS LE Review
Quest Beyondtrustcloud.com
What Happened To Anna Citron Lansky
Hanger Clinic/Billpay
Td Small Business Banking Login
Is The Yankees Game Postponed Tonight
Busted Campbell County
Football - 2024/2025 Women’s Super League: Preview, schedule and how to watch
Ihub Fnma Message Board
Strange World Showtimes Near Savoy 16
Urban Dictionary Fov
What Equals 16
Bay Area Craigslist Cars For Sale By Owner
Divina Rapsing
Violent Night Showtimes Near Johnstown Movieplex
Rgb Bird Flop
Osrs Important Letter
Otis Inmate Locator
Mosley Lane Candles
Khatrimmaza
Aladtec Login Denver Health
Wbli Playlist
Pickle Juiced 1234
Craigslist Car For Sale By Owner
Gwu Apps
World History Kazwire
Toth Boer Goats
Nearest Ups Office To Me
Mars Petcare 2037 American Italian Way Columbia Sc
MSD Animal Health Hub: Nobivac® Rabies Q & A
Danielle Ranslow Obituary
Engr 2300 Osu
Great Clips Virginia Center Commons
Avance Primary Care Morrisville
Bustednewspaper.com Rockbridge County Va
Tommy Bahama Restaurant Bar & Store The Woodlands Menu
Tyco Forums
25 Hotels TRULY CLOSEST to Woollett Aquatics Center, Irvine, CA
Ouhsc Qualtrics
Msatlantathickdream
Inloggen bij AH Sam - E-Overheid
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 5783

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.