Project

General

Profile

Revision b0dc3a2e

Added by Julien Enselme over 7 years ago

Update to Drupal 7.52

View differences:

drupal7/includes/database/database.inc
296 296
   */
297 297
  protected $prefixReplace = array();
298 298

  
299
  /**
300
   * List of escaped database, table, and field names, keyed by unescaped names.
301
   *
302
   * @var array
303
   */
304
  protected $escapedNames = array();
305

  
306
  /**
307
   * List of escaped aliases names, keyed by unescaped aliases.
308
   *
309
   * @var array
310
   */
311
  protected $escapedAliases = array();
312

  
299 313
  function __construct($dsn, $username, $password, $driver_options = array()) {
300 314
    // Initialize and prepare the connection prefix.
301 315
    $this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : '');
......
919 933
   * For some database drivers, it may also wrap the table name in
920 934
   * database-specific escape characters.
921 935
   *
922
   * @return
936
   * @return string
923 937
   *   The sanitized table name string.
924 938
   */
925 939
  public function escapeTable($table) {
926
    return preg_replace('/[^A-Za-z0-9_.]+/', '', $table);
940
    if (!isset($this->escapedNames[$table])) {
941
      $this->escapedNames[$table] = preg_replace('/[^A-Za-z0-9_.]+/', '', $table);
942
    }
943
    return $this->escapedNames[$table];
927 944
  }
928 945

  
929 946
  /**
......
933 950
   * For some database drivers, it may also wrap the field name in
934 951
   * database-specific escape characters.
935 952
   *
936
   * @return
953
   * @return string
937 954
   *   The sanitized field name string.
938 955
   */
939 956
  public function escapeField($field) {
940
    return preg_replace('/[^A-Za-z0-9_.]+/', '', $field);
957
    if (!isset($this->escapedNames[$field])) {
958
      $this->escapedNames[$field] = preg_replace('/[^A-Za-z0-9_.]+/', '', $field);
959
    }
960
    return $this->escapedNames[$field];
941 961
  }
942 962

  
943 963
  /**
......
948 968
   * DatabaseConnection::escapeTable(), this doesn't allow the period (".")
949 969
   * because that is not allowed in aliases.
950 970
   *
951
   * @return
971
   * @return string
952 972
   *   The sanitized field name string.
953 973
   */
954 974
  public function escapeAlias($field) {
955
    return preg_replace('/[^A-Za-z0-9_]+/', '', $field);
975
    if (!isset($this->escapedAliases[$field])) {
976
      $this->escapedAliases[$field] = preg_replace('/[^A-Za-z0-9_]+/', '', $field);
977
    }
978
    return $this->escapedAliases[$field];
956 979
  }
957 980

  
958 981
  /**
......
1313 1336
   *   also larger than the $existing_id if one was passed in.
1314 1337
   */
1315 1338
  abstract public function nextId($existing_id = 0);
1339

  
1340
  /**
1341
   * Checks whether utf8mb4 support is configurable in settings.php.
1342
   *
1343
   * @return bool
1344
   */
1345
  public function utf8mb4IsConfigurable() {
1346
    // Since 4 byte UTF-8 is not supported by default, there is nothing to
1347
    // configure.
1348
    return FALSE;
1349
  }
1350

  
1351
  /**
1352
   * Checks whether utf8mb4 support is currently active.
1353
   *
1354
   * @return bool
1355
   */
1356
  public function utf8mb4IsActive() {
1357
    // Since 4 byte UTF-8 is not supported by default, there is nothing to
1358
    // activate.
1359
    return FALSE;
1360
  }
1361

  
1362
  /**
1363
   * Checks whether utf8mb4 support is available on the current database system.
1364
   *
1365
   * @return bool
1366
   */
1367
  public function utf8mb4IsSupported() {
1368
    // By default we assume that the database backend may not support 4 byte
1369
    // UTF-8.
1370
    return FALSE;
1371
  }
1316 1372
}
1317 1373

  
1318 1374
/**

Also available in: Unified diff