Project

General

Profile

Actions

Feature #15208

closed

Best Practice: a) Funktion Path::join() besprechen, b) cache

Added by Carsten Rose over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Enis Nuredini
Target version:
-
Start date:
17.12.2022
Due date:
% Done:

0%

Estimated time:
Discuss:
Prio Planung:
No
Vote:

Description

    public static function join(...$pathPartsToAppend): string {
        $parts = $pathPartsToAppend;

        // concatenate all parts (arrays are flattened)
        $path = '';
        array_walk_recursive($parts, function ($part) use (&$path) {

            // filter out empty string and null arguments
            if (is_null($part) || $part === '') {
                return;
            }

            // first part added without '/'
            if ($path === '') {
                $path .= $part;
            } else {
                $part = (string)$part;

                $path .= ((($part[0] ?? '') === '/')?'':'/') . $part;
            }
        });

        // remove multiple occurrences of '/' (but keep http://)
        if (preg_match('/^\w*:\/\//', $path, $match)) {
            $protocol = $match[0];
            $path = substr($path, strlen($protocol));
        } else {
            $protocol = '';
        }
        $path = preg_replace('/\/{2,}/', '/', $path);

        return $protocol . $path;
    }

Files


Related issues

Related to QFQ - Feature #5715: PDF CachingClosedCarsten Rose20.03.2018

Actions
Actions #1

Updated by Carsten Rose over 1 year ago

  • Was ist das Problem DB in in buildCacheDate zu instantieren?
  • Was waere eine gutest Best Practice?
  • Bei einem Report mit 100 Downloadlinks, und pro Downloadlink 5 Referenzen auf DB Records: wieviel Queries werden gefeuert wenn die Seite aufgerufen wird?

Actions #2

Updated by Carsten Rose over 1 year ago

Was koennte man hier besser machen?

Actions #3

Updated by Carsten Rose over 1 year ago

Naming System Parameter

Actions #4

Updated by Carsten Rose over 1 year ago

  • Bei 5 Soruces wird strtotime() 5-mal aufgerufen: warum nicht $cachedFileModified einmal konvertieren?
  • Was ist das Problem bei Unix-Timestamps?

Actions #5

Updated by Carsten Rose over 1 year ago

  • Tracker changed from Support to Feature
Actions #6

Updated by Carsten Rose over 1 year ago

Actions #7

Updated by Carsten Rose over 1 year ago

  • Status changed from New to Closed
  • Target version deleted (24.11.0)

Mit PR,JH,EN besprochen

Actions

Also available in: Atom PDF