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().:

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: Move cryptographic functions to Crypt component
#2017345: Drupal\Component\Gettext\PoStreamReader calls get_t()
#2033193: Move PhpStorageFactory to Core
#2043773: Replace php function wrappers in file.inc with a Drupal\Core\File\FileSystem class
#2043757: Remove drupal_(string) methods out of diffengine
#2102499: Convert DiffEngine to settings

Comments

tim.plunkett’s picture

Title: Drupal-agnostic components should not be calling Drupal functions » [meta] Drupal-agnostic components should not be calling Drupal functions
catch’s picture

Category: bug » task
Priority: Major » Critical

Adjusting status a bit. This is very silly but it's not a functional bug.

It'd be good if we could move these PHP wrapper functions to a component rather than move the components to Core. That also might mean less files to load by _drupal_bootstrap_code() in the end.

podarok’s picture

#2 sounds reasonable !!!

podarok’s picture

Issue summary: View changes

Adding linked issues.

ParisLiakos’s picture

Issue summary: View changes

added PoStreamReader

catch’s picture

Issue summary: View changes

Adding PhpStorage

msonnabaum’s picture

When appropriate, these just need to be in Component. Pretty sure our strtolower is already.

dawehner’s picture

Just one subissue: #2043757: Remove drupal_(string) methods out of diffengine

The problem is that on the longrun we have to accept that for example the diffengine relies on drupal_render, which will never be a component. Components are only allowed to use other components code.

dawehner’s picture

dawehner’s picture

Issue summary: View changes

Add issue.

catch’s picture

Issue summary: View changes

Updated issue summary.

catch’s picture

Issue summary: View changes

Updated image summary.

catch’s picture

Issue summary: View changes

Updated issue summary.

catch’s picture

Status: Active » Closed (duplicate)
ParisLiakos’s picture

After #1848266: Convert Diff into a proper, PSR-0-compatible PHP component went in, everything is finally in order.
how about a test to avoid future regressions though?
#2282673: Add a PHPunit test for not using Drupal\Core code in Drupal\Component