Quantcast
Viewing all articles
Browse latest Browse all 291721

Drupal-agnostic components should not be calling Drupal functions

Anything that lives in /core/lib/Drupal/Component should function independently without having Drupal installed or available. However, digitalfire has discovered that Drupal\Component\Uuid\Com (which would only be used on Windows) calls drupal_strtolower().:

<?php
class Com implements UuidInterface {
  public function
generate() {
   
// Remove {} wrapper and make lower case to keep result consistent.
   
return drupal_strtolower(trim(com_create_guid(), '{}'));
  }
}
?>

Grepping in Component found the following function calls in violation:

Archiver/ArchiveTar.php:            @drupal_unlink($this->_temp_tarname);
Archiver/ArchiveTar.php:            @drupal_unlink($this->_temp_tarname);
Archiver/ArchiveTar.php:            @drupal_unlink($this->_temp_tarname);
Archiver/ArchiveTar.php:            @drupal_unlink($this->_tarname);
Archiver/ArchiveTar.php:                // Changed the code to use drupal_mkdir() instead of mkdir().
Archiver/ArchiveTar.php:                if (!@drupal_mkdir($v_header['filename'], 0777)) {
Archiver/ArchiveTar.php:                  @drupal_unlink($v_header['filename']);
Archiver/ArchiveTar.php:            if (!@drupal_unlink($this->_tarname.".tmp")) {
Archiver/ArchiveTar.php:        // Changed the code to use drupal_mkdir() instead of mkdir().
Archiver/ArchiveTar.php:        if (!@drupal_mkdir($p_dir, 0777)) {
Diff/DiffEngine.php:    if (drupal_strlen($line) > $this->MAX_XREF_LENGTH()) {
Diff/DiffEngine.php:        $word = drupal_substr($word, 1);
Diff/DiffEngine.php:      if ( drupal_strlen( $line ) > $this->MAX_LINE_LENGTH() ) {
Diff/DiffEngine.php:            if (strpos($piece, '<') === 0 && drupal_substr($piece, drupal_strlen($piece) - 1) === '>') {
Diff/DiffEngine.php:            if ($piece === '' || (strpos($piece, '<') === 0 && drupal_substr($piece, drupal_strlen($piece) - 1) === '>'&& drupal_strtolower(drupal_substr($piece, 1, 3)) != 'img')) {
Diff/DiffEngine.php:      if (strpos($piece, '<') === 0 && drupal_substr($piece, drupal_strlen($piece) - 1) === '>') {
Diff/DiffEngine.php:      elseif (isset($next) && strpos($next, '<') === 0 && drupal_substr($next, drupal_strlen($next) - 1) === '>') {
Uuid/Com.php:    return drupal_strtolower(trim(com_create_guid(), '{}'));
Uuid/Php.php:    $hex = substr(hash('sha256', drupal_random_bytes(16)), 0, 32);

Issues filed for individual components:

#1929282: Undefined function: drupal_strtolower() in com.php
#1929288: Drupal\Component\Uuid\Php cannot call drupal_random_bytes()
Todo: ArchiveTar.php
Todo: DiffEngine.php


Viewing all articles
Browse latest Browse all 291721

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>