GravityKit\GravityMigrate\Media\MediaAudit
Answers one question about a form that has just been imported: of the files its entries and
fields point at, how many are on this site, and how many still point somewhere else.
A file that did not come across leaves a URL on the source site behind. That URL keeps working for as long as the source does, so nothing errors and nothing is logged -- the migration looks complete until the source goes away, which for most migrations is soon. The only way to notice is to count, which is what this does.
Since: %ver%
Source: src/Media/MediaAudit.php:23
Details
- Kind:
class - Namespace:
GravityKit\GravityMigrate\Media
Methods
| Method | Description |
|---|---|
audit() | How many of a form's files are here, and how many are not. |
gfapi_entries() | Reads a form's entries from Gravity Forms, a page at a time. |
signature_resolver() | Resolves a signature to a URL on this site, or to one that cannot be here. |
Method Reference
audit()
public static function audit( array $forms, string $site_url, callable $entries_for, ?callable $signature_url=null ): array
How many of a form's files are here, and how many are not.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$forms | array[] | Form definitions to audit. | |
$site_url | string | This site's URL; a file served from it is here. | |
$entries_for | callable | Takes a form id, returns its entries. | |
$signature_url | callable | null | null | Resolves a signature's filename to a URL, or null when signatures cannot be resolved on this site. |
Returns
array{here:int,elsewhere:int,total:int}
Since: %ver%
Source: src/Media/MediaAudit.php:50
gfapi_entries()
public static function gfapi_entries(): callable
Reads a form's entries from Gravity Forms, a page at a time.
Returns
callable— Takes a form id, returns its entries.
Since: %ver%
Source: src/Media/MediaAudit.php:84
signature_resolver()
public static function signature_resolver(): callable
Resolves a signature to a URL on this site, or to one that cannot be here.
A signature is stored as a bare filename, so whether it arrived is a question about the disk rather than about a URL. Answering it as a URL is what lets the audit judge it the same way it judges every other file.
Omitting it is silent: \self::audit() skips every signature when no resolver is
given, so a caller without one reports a form's signatures as neither arrived nor missing.
Neither URL it returns is the file's own address. Both are sentinels carrying the on-disk
answer to \self::is_local(), the only thing that reads them: about:missing/ has no
host and can never be local, and the site's own address always is, whatever shape it has
(root, subdirectory, or a port), because is_local() judges against the same get_site_url().
Building the signature's real address instead miscounts on a site that serves its uploads from somewhere else: a file sitting on this disk reads as one that never arrived.
Returns
callable— Takes a signature filename, returns a sentinel URL, or null when this site has no signatures folder.
Since: %ver%
Source: src/Media/MediaAudit.php:127