DataSync
MMO\admin\helpers · 1 symbol · generated 30 Nov 2026
DataSync
DataSync.php:35Keeps what a site writes while it runs -- its data, its keys, the files sent from its backoffice: a target's sync.paths, its shared paths by default (Target::syncPolicy) -- the same on the target and in the project here, in either direction.
- Namespace
MMO\admin\helpers
Index
| BASE_LIMIT | a base copy is kept for a text up to this size: the three-way merge of something larger is no one's job | |
| BOTH | changed on both sides: to merge, or one side to choose | |
| LOCAL | changed here since the last sync: to push | |
| SAME | the same on both sides | |
| SUMMARY_FILES | how many files of a status a summary lists: a site never synced lists every file, and a page shows the counts | |
| TARGET | changed on the target since the last sync: to pull | |
| context readonly | ||
| full readonly | ||
| localUrls | ||
| machinePaths | ||
| owned | ||
| portable | ||
| project readonly | ||
| remote | ||
| repositories | ||
| scratch | ||
| sha | ||
| state | ||
| stateFolder | ||
| tracked | ||
| baseOf($filename) | ||
| cleanup() | Remove this run's temporary files: what was downloaded holds the site's data. | |
| compare($only) | Who changed what since the last sync. | |
| debugName() | ||
| fetch($paths) | Download the target's versions of files, as they are there. | |
| fetchRelease($paths) | Download files of the live release, as they are there. | |
| getBase($path) | ||
| getBaseFolder() | ||
| getDatabaseFiles() | ||
| getLastSync() | ||
| getMachinePaths() | ||
| getRoots() | ||
| getState() | ||
| getStateFilename() | ||
| getStateFolder() | ||
| installLocal($path, $source) | Put a file in place here: a rename, with the rights of the file it replaces (the web server writes it). | |
| isSynced($path) | ||
| local() | ||
| makePortable($path, $filename) | Make a copy of a file portable, saying what still looks absolute in it. | |
| Overall($counts) static | ||
| policy() | ||
| portable() | ||
| publish($files) | Write versions here, and on the target: what a merge decided, or the local ones (push). | |
| pull($files) | Write the target's versions here, made portable, and remember both sides hold them. | |
| push($paths) | Upload the local versions to the target. | |
| reading($command) | Run a command on the target that only reads, even in a dry run (the runner lets only a few through). | |
| readRemote($command) | Run a command on the target whose output may be long, and read that output through a file. | |
| record($path, $local, $remote, $content) | Remember that both sides now hold the same version of $path. | |
| recordDatabase($name, $mode) | Remember that a database server was pulled here or pushed there whole (data-pull, data-push): no file of it is compared, so this is all a status can say of it. | |
| releaseChanges($artifact) | What was changed on the target in the release it runs: its files compared with the artifact it was shipped from. | |
| remote() | ||
| remoteFilename($path) | ||
| remoteSums($paths) | ||
| removeLocal($path) | ||
| restoreDatabase($repository, $versions, $here) | Put a database's files on the target through its own restore: a dump made here of these versions, restored over the target's, its other files kept (no drop). | |
| saveState() | Write the state down: once per run, after everything was recorded. | |
| scratch() | ||
| scratchShell() | ||
| sha() | ||
| stamp() | ||
| Status($local, $remote, $base) static | ||
| summary($entries, $releaseChanges) | Where a target stands against this machine's copy, as a page or a script reads it: what compare found, counted and summed up in one word, the files that differ (each saying whether it is a dat… | |
| unsafe($command) | Run a command on the target even in a dry run: the temporary files of a reading, never the site's. | |
| upload($files) | Put files in place on the target, archiving what they replace first, under the target's deployment lock. | |
| __construct($context, $project, $localUrls, $stateFolder, $tracked, $repositories, $full) | ||
| __destruct() |
Constants6
BASE_LIMIT
a base copy is kept for a text up to this size: the three-way merge of something larger is no one's job
BOTH
changed on both sides: to merge, or one side to choose
LOCAL
changed here since the last sync: to push
SAME
the same on both sides
SUMMARY_FILES
how many files of a status a summary lists: a site never synced lists every file, and a page shows the counts
TARGET
changed on the target since the last sync: to pull
Properties14
context
readonly- Type
- Context
full
readonly- Type
- bool
localUrls
- Type
- array
machinePaths
owned
portable
- Type
- null | PortableContent
project
readonly- Type
- string
remote
repositories
- Type
- array
scratch
sha
state
stateFolder
tracked
- Type
- array
Methods46
baseOf($filename)
DataSync.php:171cleanup()
DataSync.php:775Remove this run's temporary files: what was downloaded holds the site's data.
| returns | void |
compare($only)
DataSync.php:308Who changed what since the last sync.
debugName()
DataSync.php:99| returns | string |
fetch($paths)
DataSync.php:431Download the target's versions of files, as they are there.
fetchRelease($paths)
DataSync.php:738Download files of the live release, as they are there.
getBase($path)
DataSync.php:139getBaseFolder()
DataSync.php:108| returns | string |
getDatabaseFiles()
DataSync.php:86| returns | array | int> the synced files that are a database's -- path => its index in $repositories: a database of files whose root is this project's (its dumps name the files as the paths here do) |
getLastSync()
DataSync.php:136getMachinePaths()
DataSync.php:194| returns | array | the folders of the project that are this machine's, never the site's data, whatever the paths say: each database's dumps (its getBackupFolder()), the jobs' state (mmo.core's JobStore), mmo.admin's .mmo/ |
getRoots()
DataSync.php:217| returns | array | the sync paths to read: an optional one is not even listed without a full copy (it is the heavy one) |
getState()
DataSync.php:111| returns | array | at: when the last sync was (null: never); files: path => {local, remote, at}; databases: name => {at, mode} |
getStateFilename()
DataSync.php:107| returns | string |
getStateFolder()
DataSync.php:106| returns | string |
installLocal($path, $source)
DataSync.php:676Put a file in place here: a rename, with the rights of the file it replaces (the web server writes it).
isSynced($path)
DataSync.php:223local()
DataSync.php:246| returns | array | string> path => sha256 of every synced file here |
makePortable($path, $filename)
DataSync.php:415Make a copy of a file portable, saying what still looks absolute in it.
Overall($counts)
staticDataSync.php:370policy()
DataSync.php:102| returns | array | Target::syncPolicy |
portable()
DataSync.php:396| returns | PortableContent | the target's urls and folders, and this machine's, made relative |
publish($files)
DataSync.php:518Write versions here, and on the target: what a merge decided, or the local ones (push).
pull($files)
DataSync.php:490Write the target's versions here, made portable, and remember both sides hold them.
push($paths)
DataSync.php:568Upload the local versions to the target.
reading($command)
DataSync.php:822Run a command on the target that only reads, even in a dry run (the runner lets only a few through).
| $command | string | |
| returns | ShellResult |
readRemote($command)
DataSync.php:801Run a command on the target whose output may be long, and read that output through a file.
record($path, $local, $remote, $content)
DataSync.php:152Remember that both sides now hold the same version of $path.
recordDatabase($name, $mode)
DataSync.php:127Remember that a database server was pulled here or pushed there whole (data-pull, data-push): no file of it is compared, so this is all a status can say of it. Written at once, the files' last sync left as it is.
releaseChanges($artifact)
DataSync.php:701What was changed on the target in the release it runs: its files compared with the artifact it was shipped from.
remote()
DataSync.php:282| returns | array | string> path => sha256 of every synced file on the target, read once |
remoteFilename($path)
DataSync.php:274remoteSums($paths)
DataSync.php:550removeLocal($path)
DataSync.php:689restoreDatabase($repository, $versions, $here)
DataSync.php:658Put a database's files on the target through its own restore: a dump made here of these versions, restored over the target's, its other files kept (no drop).
| $repository | iBackupRepository | |
| $versions | array | |
| $here = false | bool | restore it in this project rather than on the target |
| returns | void |
saveState()
DataSync.php:176Write the state down: once per run, after everything was recorded.
| returns | void |
scratch()
DataSync.php:763| returns | string | this run's temporary folder here, readable by its owner only |
scratchShell()
DataSync.php:772| returns | ShellRunner | commands on this machine's temporary files: run in a dry run too, they change nothing of the site's |
sha()
DataSync.php:786| returns | string | the sha256 command of the target |
stamp()
DataSync.php:783| returns | string | a name for this run's files on the target: when, and by whom |
Status($local, $remote, $base)
staticDataSync.php:383summary($entries, $releaseChanges)
DataSync.php:344Where a target stands against this machine's copy, as a page or a script reads it: what compare found, counted and summed up in one word, the files that differ (each saying whether it is a database's), the live release's edited files, and the database servers -- which no file holds: when each was last pulled or pushed.
| $entries | array | compare |
| $releaseChanges = null | null | array | |
| returns | array | string, lastSync: ?string, counts: array<string, int>, files: list<array{path: string, status: string, database: bool}>, more: int, release: ?array{changed: int, files: array<string, string>}, databases: array<string, ?array{at: string, mode: string}>} status: synced (nothing differs), TARGET (to pull), LOCAL (to push), BOTH (to merge) |
unsafe($command)
DataSync.php:836Run a command on the target even in a dry run: the temporary files of a reading, never the site's.
upload($files)
DataSync.php:583Put files in place on the target, archiving what they replace first, under the target's deployment lock.
__construct($context, $project, $localUrls, $stateFolder, $tracked, $repositories, $full)
DataSync.php:66| $context | Context | the target, its shell and its lock |
| $project | string | the project's folder here: where each path of a release is |
| $localUrls = [] | array | this machine's urls of the application, made relative too |
| $stateFolder = null | null | string | where the state of the syncs is kept (null: the project's .mmo/sync) |
| $tracked = [] | array | the project's files git tracks, never synced |
| $repositories = [] | array | the application's databases, getDatabaseFiles |
| $full = false | bool | $full |