# RFC: Drop sql.safe_mode

- Status: Inactive
- Authors: Johannes Schlüter johannes@php.net
- Date: 2010-03-26
- Version: 1.0
- Original: https://wiki.php.net/rfc/drop_sql.safe_mode
- Page: https://externals.io/rfc/drop_sql.safe_mode
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Discussions on the mailing list

- [\[RFC\] Removal of deprecated features](https://externals.io/message/47839.md) — started on 2010-04-08, 25 messages

---

## Introduction

sql.safe\_mode is a very old feature of PHP, not really maintained and barely understood. The documentation claims on <http://php.net/manual/en/ini.core.php#ini.sql.safe-mode>

```
  If turned on, database connect functions that specify default values will
  use those values in place of supplied arguments. For default values see
  connect function documentation for the relevant database. 
```

The documentation of the individual extensions gives no further details.

## Source-based feature analysis

According to a grep this setting is only used by the classic mysql and interbase extensions.

With the classic mysql extension sql.save\_mode will throw an E\_NOTICE and override the user provided connection settings and use php\_get\_current\_user() (the owner of the executed main script) as mySQL user and mysql default host/password, ignoring values provided by php.ini. This makes this feature unusable onsystems where the mysql socket is not located at /tmp/mysql.sock.

With interbase it will allow any username/password but (silently) override the selected database using a value provided by php.ini. Additionally it will throw an error in case a CREATE DATABASE statement is detected.

Other extensions (notably mysqli, PDO, pgsql, oci) don't respect that setting in any way. There is one request to extend it to mysqli.

## Proposal and Patch

The proposal is to drop PG(sql\_safe\_mode) and references to sql.safe\_mode from the source. A straight-forward patch will be created and committed if this RFC is accepted.

## Reasoning

This global setting has very different behavior with the two supported extensions. For using this feature with mysql one has to create a password-less MySQL account which opens attack vectors for users with any form of access to the machine.

## Related bug reports

[\#50388 MySQL safe mode support](http://bugs.php.net/bug.php?id=50388)

## Changelog
