Deletes multiple DB files by wildcard

@param string $wildcard
@param mixed $fname
@return bool
@deprecated Has severe performance issues
500930
public function _deleteByWildcard( $wildcard, $fname = false )
    {
        if ( $fname )
            $fname .= "::_deleteByWildcard($wildcard)";
        else
            $fname = "_deleteByWildcard($wildcard)";
        return $this->_protect( array( $this, '_deleteByWildcardInner' ), $fname,
                                $wildcard, $fname );
    }
990238
private boolean removeFile(File f) {
        if (Utils.fileIsFile(f)) {
            return Utils.deleteFile(f);
        } else {
            //delete directory f..
            boolean ok = true;
            //remove all the children..
            File children[] = Utils.listFiles(f);
            if (children != null) {
                for (File child : children) {
                    ok &= removeFile(child);
                }
            }
            //once children are deleted, remove the directory
            if (ok) {
                ok &= Utils.deleteFile(f);
            }
            return ok;
        }
    }
561241
public static function stringMatchesWildcard(string $wildcardPattern, string $string): bool
    {
        $pattern = '#^' . self::wildcardToRegex($wildcardPattern). '$#i';

        return (bool) preg_match($pattern, $string);
    }
1226505
public static function clear($filename)
    {
        $filename = static::path($filename);

        if (!file_exists($filename)) {
            return;
        }

        if (!unlink($filename)) {
            throw new \Exception("Unable to delete file (" . $filename . ")");
        }
    }
555466
public static function has($array, $keys, $wildcard = null)
    {
        // If the keys are null or the array is not accessible
        if (null === $keys || empty($array) || !Arr::accessible($array)) {
            return false;
        }

        // Check that every key exists in $array
        $originalArray = $array;
        foreach ((array) $keys as $key) {
            $array = $originalArray;

            // If the array has the key carry on
            if (Arr::exists($array, $key)) {
                continue;
            }

            // Break up the key into segments and drill into the array
            $segments = explode('.', $key);
            foreach ($segments as $k => $segment) {
                // If the segment is a wildcard
                if ($segment === $wildcard && !empty($array)) {
                    // If this is the last segment then the array has the key
                    if ($k + 1 === count($segments)) {
                        break;
                    }
                    // If we are still considering an array, drill into every possibility
                    if (Arr::accessible($array)) {
                        // Check that at least one possibility contains the (sub)key
                        $subKey = implode('.', array_slice($segments, $k + 1));
                        $found  = array_reduce($array, function ($f, $item) use ($subKey, $wildcard) {
                            return $f || static::has($item, $subKey, $wildcard);
                        }, false);
                        if (!$found) {
                            return false;
                        } else {
                            break;
                        }
                    }
                }
                // Otherwise continue to drill into $array
                if (!empty($array) && Arr::accessible($array) && Arr::exists($array, $segment)) {
                    $array = $array[$segment];
                    continue;
                }
                return false;
            }
        }

        return true;
    }
178173
final public function delete($name) {

        if ( array_key_exists($name, $this->rpc_methods) ) {

            unset($this->rpc_methods[$name]);

            $this->logger->debug("Deleted method $name");

            return true;

        } else {

            $this->logger->warning("Cannot delete method $name: entry not found");

            return false;

        }

    }
1140622
protected static function matchRegexpCode( $wildcard )
    {
        $matchWilcard = $wildcard['source_url'];
        $matchWilcardList = explode( "*", $matchWilcard );
        $regexpList = array();
        foreach ( $matchWilcardList as $matchWilcardItem )
        {
            $regexpList[] = preg_quote( $matchWilcardItem, '#' );
        }
        $matchRegexp = implode( '(.*)', $regexpList );

        return "#^$matchRegexp#i";
    }
1283122
public function deleteDb($name)
    {
        if (isset($name) && !empty(trim($name))) {
            $sql = "DROP DATABASE `{$name}` ";

            return $sql;
        } else {
            return false;
        }
    }
1025095
private function actionDelete()
    {
        $baseName = substr($this->path, 0, strrpos($this->path, '.'));
        $files = glob($baseName . '.*');
        if (!is_array($files))
        {
            $files = array();
        }
        $files2 = glob($baseName . '-*');
        if (!is_array($files2))
        {
            $files2 = array();
        }

        $files = array_merge($files, $files2);

        foreach ($files as $file)
        {
            @unlink($file);
        }
    }
750925
private function selectedMonthInFormWithWildcard($wildcard)
    {
        $arguments = $this->getRequestArguments();
        $months = explode(',', $arguments['months']);
        // If there is no selection, use the previous month (i.e. the item at
        // index 0 of the monthsArray() result).
        if ($months[0] == '') {
            $monthKeysArray = array_keys($this->monthsArray());
            $months = [$monthKeysArray[1]];
        }

        $dates = [];
        $this->addSearchTermsToList($months, $dates, $wildcard);

        return $dates;
    }
663896
protected function _deleteInner( $filePath, $fname )
    {
        if ( !$this->_query( "UPDATE " . $this->dbTable( $filePath ) . " SET mtime=-ABS(mtime), expired=1 WHERE name_hash=" . $this->_md5( $filePath ), $fname ) )
            $this->_fail( "Deleting file $filePath failed" );
        return true;
    }
197866
public function deleteBackupFiles($lang_folder_path, $days = 0, $dryRun = false, $ext = 'php')
    {
        if ($days < 0) {
            return false;
        }

        try {
            $dir_lang = $this->getLangPath($lang_folder_path);
        } catch (Exception $e) {
            switch ($e->getCode()) {
                //@codeCoverageIgnoreStart
                case self::NO_LANG_FOLDER_FOUND_IN_THESE_PATHS:
                    $this->messageBag->writeError("No lang folder found in these paths:");
                    foreach ($e->getParameter() as $path) {
                        $this->messageBag->writeError("- ".$path);
                    }
                    break;
                //@codeCoverageIgnoreEnd

                case self::NO_LANG_FOLDER_FOUND_IN_YOUR_CUSTOM_PATH:
                    $this->messageBag->writeError('No lang folder found in your custom path: "'.$e->getParameter().'"');
                    break;
            }

            return false;
        }

        $return = true;

        foreach ($this->getBackupFiles($dir_lang) as $file) {
            $fileDate = $this->getBackupFileDate($file, $ext);

            // @codeCoverageIgnoreStart
            // Cannot happen because of glob but safer
            if (is_null($fileDate)) {
                $this->messageBag->writeError('Unable to detect date in file '.$file);
                $return = false;

                continue;
            }
            // @codeCoverageIgnoreEnd

            if ($this->isDateOlderThanDays($fileDate, $days)) {
                if ($dryRun === true) {
                    $deleted = true;
                } else {
                    $deleted = unlink($file);
                }

                if ($deleted === true) {
                    $this->messageBag->writeInfo('Deleting file '.$file);
                } // @codeCoverageIgnoreStart
                else {
                    $this->messageBag->writeError('Unable to delete file '.$file);

                    $return = false;
                }
            } // @codeCoverageIgnoreEnd
            else {
                $this->messageBag->writeInfo('Skip file '.$file.' (not older than '.$days.'day'.Tools::getPlural($days).')');
            }
        }

        return $return;
    }
962129
public function deleteFileByName($filename)
    {
        $destinationPath = $this->getDestinationPath();
        $destination = $destinationPath . '/' . $filename;

        if (file_exists($destination)) {
            $files = $this->getFiles();
            foreach ($files as $key => $file) {
                if ($file->file == $filename) {
                    unlink($destination);
                    unset($files[$key]);
                }
            }

            $files = array_values($files);
            $this->repository->files = $files;
            $this->save();
        }
    }
1105098
public function clearTable(string $tableName): bool
    {
        $delete = new DeleteQuery($this->db);

        return $delete->from($tableName)->execute();
    }
332690
public function delete(string $filename): DeleteCommand
    {
        /** @var DeleteCommand $command */
        $command = $this->builder->build(DeleteCommand::class);
        $command->byFilename($filename);

        return $command;
    }
823695
public function removeFile( $fileName )
	{
		$this->connection->checkConnection();
		return @ftp_delete( $this->connection->getResource(), $fileName );
	}
1030723
public static function localDelete(string $path, string  $fileName) : bool
    {
        if (is_file($path . $fileName)) {
            unlink($path . $fileName);
        } else {
            return false;
        }
        return true;
    }