Repository navigation
Conversation
…tracted beside the installed one An archive whose single top folder is the module's own name (a custom module repository can serve one) was still handled in the old order: delete the installed folder, extract, rename. A failed extract ended with a success alert and the module gone or partial. It now unpacks into <type>/<name>.update.tmp/ beside the module, every entry is measured as for a GitHub archive, and the installed folder goes only once the new copy is complete. The staging name is fixed so a leftover of a killed request is cleared by the next update; no module can carry it since the installer's name charset has no dot. If the staging folder cannot be created the action stops with an alert and nothing is deleted. A GitHub archive and any other shape (files at the root, mixed top folders) are handled exactly as before. Tests: an own-name archive that cannot be extracted, one whose file lands short, a stale staging folder from a killed request, and the existing clean own-name update now checked through the staging path.
…contents() where filesize() is disabled The size loop ran only where filesize() exists, so on a host with filesize in disable_functions every entry was accepted unmeasured and a truncated archive (central directory 20 bytes, data 10) was installed under a success alert. extractedSize() reads the size with the first function the host leaves enabled: filesize(), else stat(), else file_get_contents(), which the core needs everywhere; a file none of them can read counts as missing. Test: the module-install probe run with disable_functions=filesize and with filesize,stat over an installed theme and a doctored-size GitHub archive expects the danger alert and the old folder intact. The probe's redirect() now exits in the module modes, as the real one does, so a failure branch does not run on into the success one; the probe helper takes the list of disabled functions.
…renamed in; a link at the staging path is pinned Once the whole archive was on disk (a GitHub archive, or one whose top folder is the module's own name), the installed folder was deleted and the new one renamed in. A subfolder the PHP user cannot empty (uploaded by FTP as another user, or read-only) stopped the delete halfway, and rename() then met a non-empty folder and threw: an uncaught exception, the module half-deleted and the new copy stranded beside it. The installed folder is now renamed aside to <name>.old.tmp (a rename needs write on themes/ or plugins/ only, so such a subfolder moves with it), the new folder is renamed into place, and the aside copy is removed where it can be, without warnings (removeQuietly()). A remnant stays as <name>.old.tmp: loadPlugins() and the Plugins tab never pick it up, and the Themes tab lists it only while its theme.php is left. If the rename aside fails, the installed folder is deleted first, as before; if the rename into place fails after it, the aside copy is renamed back and the action stops with a danger alert. A stale <name>.old.tmp is cleared first; a link there, or as the installed folder, is removed, never followed or renamed. A GitHub or own-name archive renames only the folder it extracted (the -main probe is for the other shapes), and the removal of the staging folder after the swap has the link guard too. Tests: links at foo.update.tmp and foo.old.tmp pointing at an outside folder are removed and the outside file kept (fails with a trailing slash on either path); an installed foo whose subfolder cannot be emptied (0555) or opened (0000), updated from a foo/ and a foo-master/ archive, lands with the remnant in foo.old.tmp (fails on 3f2c974).
… never blocks the swap The installed folder was renamed aside to one fixed name, <name>.old.tmp. A subfolder the PHP user cannot empty stays in that folder after the update, so at the next update of the module the rename aside met a non-empty folder and failed; the fallback deleted the installed folder first, stopped at a locked folder uploaded again since, and the rename in threw: the uncaught exception and the half-deleted module the swap was meant to end. The aside name is now new for every request, made by tempPath() (<name>.old.<8 hex>.tmp), and the remnants of earlier updates are cleared first, best effort, with the glob pattern writeFile() uses for the names tempPath() makes, through removeQuietly() (a link is removed, never followed). A remnant that cannot be emptied stays and never blocks a later update. The fallback to the old order is left for a rename aside the parent folder refuses (permissions, a file held open on Windows), where the same refusal stops that order too. Tests: two consecutive updates from a foo/ archive, a locked 0555 folder uploaded into foo before each: both land, foo holds the new copy each time, and each upload stays in its own remnant (fails on 87d98f5: the second update throws "Theme or plugin not installed"). The link test plants its link at a remnant name, foo.old.0123abcd.tmp, next to a plain remnant folder: both go and the outside file is kept (fails without the sweep, with GLOB_MARK, or with a sweep that follows links). The locked-folder test finds its remnant by pattern.
…touched Where the installed folder refused the rename aside (locked or immutable, a mount point, a file held open in it on Windows), the GitHub and own-name arms fell back to deleting it first. On such a folder the delete gets through the files in its subfolders before the same refusal stops the rename into place: the action threw "Theme or plugin not installed" with the module stripped to its top-level files and the new copy stranded beside it (chflags uchg on macOS, both archive shapes). There is no fallback now. When the rename aside is refused, or tempPath() throws (random_bytes() with no source of randomness), the new copy is removed, the installed folder is left as it was, and the action stops with "Could not move the installed version aside. Nothing was changed." The aside name is made only for an installed folder of those two shapes, so the other ZIP shapes never call tempPath(). The comment no longer says the installed folder is deleted first. The remnant sweep and writeFile()'s temp sweep escape [, * and ? in the path with bracket expressions: with the site at .../site[1]/ both missed their own leftovers and matched those under .../site1/. Tests: an installed foo that cannot be renamed aside (tempPath() stubbed to a path in a folder that does not exist, refused on every platform, as root too) or gets no aside name (the stub throws), updated from a foo/ and a foo-master/ archive: danger alert, foo byte-identical, no staging, foo-master or aside folder left (each case fails on e4f75c4: a success alert over the deleted folder, or the uncaught Exception). A site at site[1] beside site1: an update and a save there sweep only their own leftovers (fails with either escape removed).
…mage content) takes the delete-then-rename order On overlayfs with redirect_dir off (as in Docker Desktop's engine), a folder that comes from a lower layer refuses rename() with EXDEV, while it can be deleted and a folder made in the upper layer can be renamed in. In the project's image, ghcr.io/robiso/wondercms:3.7.0, the bundled Sky theme is such a folder: since 9a41318 every update of it stopped with "Could not move the installed version aside. Nothing was changed.", where 3ad007a and e4f75c4 deleted it and renamed the new copy in. The rename aside now reads its own warning, error_clear_last() before it and error_get_last() after. A refusal whose message ends in "cross-device link", in any case (glibc says "Invalid cross-device link", macOS and musl "Cross-device link"), deletes the installed folder, with the link guard, and renames the new copy in. Every other refusal, and a tempPath() that throws, still removes the new copy and leaves the installed folder as it was. The match is anchored at the end of the message, where PHP puts the reason, so a path holding the words cannot match. Tests: an installed foo whose aside path is in /dev (a filesystem of its own on Linux and macOS, so the rename aside gets a real EXDEV and PHP's own message), updated from a foo/ and a foo-master/ archive: success alert, foo holds only the new copy, no staging, extracted or aside folder left. It fails on 9a41318 with the danger alert (on macOS, and on Linux in the image), and with the delete left to a folder that was not installed. The refusal test fails if every refusal deletes; both fail if the match reads a path in the message instead of its reason. In the image, with this index.php copied in, the bundled Sky updates from a sky/ and a sky-master/ archive.
…y when every part of it can be On the cross-device path (a folder from a lower overlay layer, such as the bundled Sky in ghcr.io/robiso/wondercms:3.7.0) nothing is moved aside before the delete. A subfolder the PHP user cannot empty (one the image ships owned by root, or one made read-only) stopped the delete halfway; the rename in then met a non-empty folder and threw "Theme or plugin not installed", with theme.php gone and the new copy stranded in <name>.update.tmp/ or <name>-master/. A subfolder it cannot open threw UnexpectedValueException from DirectoryIterator. That path now runs only when a small private check, canEmpty(), finds that the folder and every folder under it can be listed and written to, links not followed. Otherwise the update takes the refusal every other refused rename takes: the new copy is removed and the installed folder is left as it was. The check covers the GitHub arm too, where 372 already deleted first and threw on this shape. The refusal alert now names the folder and what to check: "Check that <type>/<name> is not locked or in use and that the web server can delete everything in it, then try again." Two comments now also name a plugin error handler that throws on the warning, and tempPath()'s second caller. Tests: on the cross-device path, an installed foo with a locked/ subfolder that cannot be emptied (0555, from a foo/ and a foo-master/ archive) or opened (0000, from a foo/ archive): the danger alert naming themes/foo, foo exactly as before, no staging, extracted or aside folder left. Each case fails on f28f4c6 (the exception, or UnexpectedValueException for 0000), and with the check removed, made shallow or without its try/catch; the cross-device test fails if the check always refuses. In the image, with a folder owned by root planted in Sky, f28f4c6 threw with Sky stripped to that folder; this index.php refuses with Sky md5-identical and nothing left beside it, and a plain Sky still updates from a sky/ and a sky-master/ archive.
…rged over, as 3.7.1 did, never left half-deleted
…merged child by child; the destination-link check is pinned
…the update merges into it A volume mounted on a module subfolder (a Docker -v on themes/sky/css) does not stop the rename aside: the mount went with the installed folder to <name>.old.<hex>.tmp/, the best-effort removal emptied the volume there and left it mounted in the remnant, and the owner saw success. After a remount the theme had an empty css/. Before this change the own-name update extracted over the mount and kept it filled. Before the rename aside, a small private check, holdsMount(), walks the installed folder's subfolders (links not followed) and compares their device with the folder's own through a protected deviceOf() (stat()'s dev; where stat() is disabled it finds no mount, as before). A folder with a mount below it is not renamed aside: it takes the existing cross-device path (canEmpty() first, the quiet delete, then the merge of the new copy into what is left), so the mount stays where it is and ends up holding the new files. A module folder that is itself a mount point is unchanged (its rename is refused and nothing is touched). mergeInto(): where a link at a file's destination cannot be removed, the file is skipped and reported (the partial alert) instead of being handed to rename(), which across a mount point copies through the link. The docblock now says a link in the way is never written through. Tests: deviceOf() stubbed so themes/foo/css is on a device of its own, with a stuck subfolder keeping css/ in place through the delete as a mount point does, from a foo/ and a foo-master/ archive: the success alert alone, css/ the same folder (inode unchanged) holding the new files, no aside, staging or extracted folder left. It fails on f25ea5a with only the deviceOf() seam added (css/ moved aside, the new css/ a different folder). On macOS, an HFS+ RAM disk mounted at themes/foo/css through the real action, both archives: the same, the volume still mounted at css/; then an undeletable link on the volume is reported by the merge and its target left as it was. It is skipped where hdiutil is absent (CI); it fails on f25ea5a (the mount moved into the remnant) and with the new link skip removed (the copy wrote through the link).
…below it, keeps its place; the update merges into it holdsMount() now also answers yes in two shapes the device walk could not see, so the update skips the rename aside and takes the cross-device path (canEmpty(), the quiet delete, mergeInto()), as it already does for a volume on another device below the module: - A volume mounted on the module folder itself (a Docker -v on themes/sky): every subfolder shares its device, and on macOS the rename aside took the mount along, emptied it in the remnant and left a plain folder with the new files. The folder's device is now compared with its parent's too. - A bind mount below the module whose source is on the site's own filesystem: it keeps the device, and Linux renames a folder with a mount below it, so the mount travelled into the remnant. Where /proc/self/mountinfo can be read, any mount point at or under the module folder counts as a mount; field 5 is the mount point, its octal escapes (space, tab, newline, backslash) decoded in one pass. The file is read through a new protected mountInfo(), '' where there is no such file or it cannot be read (not Linux, open_basedir), so the device walk alone decides there, as before. A refusal on that path comes before any move was tried (a read-only volume), so its alert now begins "Could not update themes/<name>: it cannot be written. Nothing was changed." instead of "Could not move the installed version aside". Tests: a stubbed deviceOf() puts themes/foo and everything in it on a device of its own, a stuck subfolder keeping the folder in place through the delete as a mount point does, from a foo/ and a foo-master/ archive: the success alert alone, themes/foo the same folder (inode unchanged) holding the new files, nothing left beside it; then with a read-only css/ the refusal with the new wording, nothing changed. It fails on d7860ba (the folder moved aside). holdsMount() with a stubbed mountInfo(): a mount point under the module and on the module folder itself count, unrelated ones (/, /proc, the parent, a sibling sharing the prefix) do not, an escaped space and a backslash before 040 decode once; then the update with a bind mount listed at themes/foo/css from both archives: css/ the same folder holding the new files.
|
Greenlit after ten gate rounds (the maintainer allowed rounds beyond the usual three). Round 10: Reviewer 1 Fable 5.1 PASS LOW-only at 81e9e5f (a volume mounted at the module folder itself on a real HFS+ RAM disk: success, inode and device unchanged, new files on the volume; read-only volume: the new refusal, nothing changed; the mountinfo parse pinned through the seam, mutants M1 to M5 bite; head suite 318, merged 322; CI 16/16). Reviewer 2 Opus 5.5 (claude-opus-5-5) PASS LOW-only (the same volume shape end to end on both archive arms; 15 more mountinfo cases incl. a file bind mount, escapes, a 3000-line list; d7860ba moves the volume aside, the head does not). Earlier rounds, each closed by a fix and re-verified: r1 locked subfolder and staging-link test; r2 leftover aside blocking the next update; r3 destructive delete-first fallback on an immutable folder; r4 Docker overlay layers refusing every rename; r5 a partial delete on those layers; r6 a pre-check that cannot be complete (merge fallback added); r7 a folder that cannot cross a mount point and the destination-link check; r8 a volume mounted inside the module; r9 a volume on the module itself and a same-filesystem bind mount. Head: 81e9e5f. Open LOWs: the mountinfo comparison is not realpath()'d; an open_basedir that excludes /proc plus a plugin error handler that throws on silenced warnings crashes before any change (such a handler already breaks every save on 3.7.1); a deleted mount point below the module still counts; the known php -S port race in untouched backup tests. No money path, no UI change. Merge HELD for the maintainer's final panel on code size (panel 38), which may choose a smaller shape; this comment records the gate result for 81e9e5f. |
|
Closed without merging, by the maintainer's decision after the final twelve-seat review (option c, 8 of 12): #441 already protects every module on the official list and both documented custom-repository examples (GitHub archives); the two shapes this PR adds (a custom zip whose top folder is the module's own name; a host that disables filesize()) are stated limits in the 3.7.2 notes, admin-only and not security; and the 212 lines it grew to over ten review rounds, most of them for filesystem shapes a reviewer had to construct, are out of proportion for WonderCMS. The branch stays for reference; a 60-line version (staging folder plus measured entries, then the existing order) is the shape to take if the own-name case is ever reported by a site. |
What
A theme or plugin archive whose single top folder is the module's own name (
foo/theme.php,foo/css/style.css) is now extracted beside the installed folder too, the way #441 does it for a GitHub archive (foo-master/,foo-main/). The installed folder is touched only after every entry of the new copy is on disk with the size the archive declares, and then, for both shapes, it is renamed aside and the new copy renamed in, instead of being deleted in place first.Why
#441 kept the old order (delete, extract, rename) for an own-name archive, because extracting
foo/straight intothemes/would merge it into the livethemes/foo/. A custom module repository (Settings, custom modules) can serve exactly that shape. For it the installed module was still deleted before an unchecked extract, so a failed extract (a collision inside the archive, a disk that fills) ended with "Successfully installed/updated" while the module was gone or partial.The staging folder
An own-name archive is extracted into
<type>/<name>.update.tmp/, inside the samethemes/orplugins/folder, so the finalrename()stays on one filesystem. The name is fixed, so a leftover of a request that was cut short is cleared by the next update of that module; no module can carry it because the installer's name charset has no dot. A link at that path is removed, never followed. If the staging folder cannot be created the action stops with an alert and nothing is deleted. On failure the staging folder is removed and the installed version is left in place; on success the new copy is swapped in (below) and the empty staging folder is removed. The staging folder exists only during the request (or after a killed one, until the next update); its top level holds<name>/, not an entry file, so it never shows in the Themes or Plugins tab andloadPlugins()never loads it.A GitHub archive is extracted as before. Any other shape (files at the archive root, or mixed top folders) keeps the old order, as before.
The swap (GitHub and own-name archives)
Once the whole archive is on disk, the installed folder is renamed aside to
<type>/<name>.old.<8 hex>.tmp, a name new for every request (made bytempPath(), which names the atomic saves' temp files), the new folder is renamed into place, and the aside copy is then removed where it can be. A rename needs write permission onthemes/orplugins/only, so a subfolder the PHP user cannot empty (uploaded by FTP as another user, or made read-only) moves aside with the old copy. Before, the delete stopped at that subfolder, the rename met a non-empty folder and threw: an uncaught exception (HTTP 500), the module half-deleted and the new copy stranded beside it. A GitHub archive did the same on 372.writeFile()uses for its temp files, with a[,*or?in the site's path escaped so it matches only itself). As the aside name is new each time, a remnant never blocks a later update; an update that cannot empty its aside copy leaves one more, and all of them go once they can be removed.loadPlugins()and the Plugins tab never pick one up (they look for<folder>/<folder>.php); the Themes tab lists one only while itstheme.phpis left.chflags uchg,chattr +i; a file in it held open on Windows; permissions on the parent), or no aside name can be made (tempPath()throws whererandom_bytes()has no source of randomness), the new copy is removed, the installed folder is left exactly as it was, and the action stops with "Could not move the installed version aside. Nothing was changed. Check that<type>/<name>is not locked or in use, then try again." Nothing is deleted first. On such a folder a delete gets through the files in its subfolders before the same refusal stops the rename into place, so deleting first ended in an uncaught exception with the module stripped to its top-level files and the new copy stranded beside it: what 372 does for a GitHub archive on that shape. 372's own-name order deleted what it could and extracted into the folder; it now refuses the same way, and the update lands once the folder can be moved.tempPath()is called only here, so the other ZIP shapes never reach it.EXDEV; PHP's warning ends in "Invalid cross-device link" on glibc, "Cross-device link" on macOS and musl). A folder that comes from a lower layer of an overlay filesystem refuses every rename that way, yet it can be deleted, and a folder made in the upper layer can be renamed in. The bundled Sky theme in the project's Docker image (ghcr.io/robiso/wondercms:3.7.0, Docker's overlayfs withredirect_diroff) is such a folder, so every update of it was refused. For that refusal only, the installed folder is deleted and the new copy renamed in, as 372 does for a GitHub archive; there is no aside copy to go back to, so two guards stand in for it, for both archive shapes. The front door is a small private helper,canEmpty(): the folder and every folder under it can be listed and written to, links not followed (whereis_writable()is disabled it cannot tell, so it says no). Where it says no (a subfolder the image ships owned by root, or one made read-only or unreadable) the action takes the refusal above, with "and that the web server can delete everything in it" added to the alert, and nothing is touched. Where it says yes, the delete runs without warnings (removeQuietly()), and if the installed folder still exists afterwards, because a part of it the check cannot foresee stayed (a volume or tmpfs mounted inside the module, another user's file in a sticky folder, a folder with write but no search permission, an immutable file), the new copy is moved into it entry by entry (mergeInto(): a file replaces the file of its name, a folder merges into the folder of its name, a link is moved and never followed, and a link at the destination is removed first, or, where it cannot be removed, left in place with the entry reported as not placed, so it is never merged into or written through; a folderrename()cannot move is made at the destination and filled entry by entry, which is the case under a mount point: PHP'srename()copies a file across one but never a folder, so with a volume or bind mount oncss/and an archive that carriescss/fonts/, 8649435 leftfonts/out with the alert below on every retry), the empty new folder is removed, and the action ends with the success alert, as 372's extract over the folder did. An entry that cannot be placed (one under the part that stayed) is left out and reported: "Some of the update could not be moved into<type>/<name>; the rest is in place. Check that the web server can replace everything in it, then update again." Nothing on this path throws, and a folder is never left half-deleted: f28f4c6 and a763bf6 stopped at such a part, the rename in met a non-empty folder and threw, an uncaught exception with the module stripped to that part and the new copy stranded beside it (372 the same for a GitHub archive). The cross-device reason is read from the rename's own warning (error_clear_last()before it,error_get_last()after), matched at the end of the message, where PHP puts it, so a path holding the words cannot match. Where a plugin's error handler swallows the warning, the refusal stands as for any other reason.-vonthemes/skyor onthemes/sky/css, a bind mount, a tmpfs) is not renamed aside. A rename takes a mount inside the folder along: on f25ea5a the mount went to<name>.old.<8 hex>.tmp/, the removal of the aside copy emptied the volume there and left it mounted in the remnant under the plain success alert, and after a remount (a reboot, a container restart) the theme had an emptycss/. macOS renames a mount point itself the same way, so a volume on the module folder went aside whole. Before the rename aside a small private helper,holdsMount(), looks for a mount in three ways, links not followed: where Linux lists this process's mounts (/proc/self/mountinfo, read by a protectedmountInfo(); field 5 is the mount point, its octal escapes for a space, tab, newline or backslash decoded in one pass), any mount point at the module folder or under it, which also finds a bind mount whose source is on the site's own filesystem and so keeps the device; then the module folder's device against its parent's (stat()'sdev, read by a protecteddeviceOf()), for a volume on the folder itself; then each subfolder's device against the folder's own. Wherestat()is disabled and no mount is listed it finds none, as before. Where one is found, the update takes the cross-device path above (thecanEmpty()front door, the quiet delete, the merge), so the mount stays where it is and ends up holding the new files, as 372's own-name extract over the folder kept it filled. On Linux a module folder that is itself a mount point refused the rename (EBUSY), so it could not be updated; it now takes the same path. A refusal there comes before any move was tried (a read-only volume, whichcanEmpty()rejects), so its alert reads "Could not update<type>/<name>: it cannot be written. Nothing was changed. Check that<type>/<name>is not locked or in use and that the web server can delete everything in it, then try again." What is left: where/proc/self/mountinfocannot be read (not Linux, oropen_basedirkeeps PHP out of/proc) the device checks decide alone, so a mount that keeps the device, or one below a folder the web server cannot list, still goes aside with the rename, as on d7860ba.removeQuietly(): what it cannot remove, or a folder it cannot open, stays.-mainfallback probe now applies to the other ZIP shapes only, so a vanished extract folder takes the rollback (or the exception) instead of a success alert over a removed module.The temp-file sweep in writeFile()
writeFile()'s sweep of stale temp files (on 372) builds its glob pattern on the file's path the same way, and it was unescaped: with the site at.../site[1]/, a save missed its own staledata/database.js.<8 hex>.tmpand removed the one under.../site1/. Both sweeps now escape the path with bracket expressions ([as[[],*as[*],?as[?]), the form the patterns already use for the hex digits, rather than with backslashes, which are path separators on Windows.Measuring where filesize() is disabled
The size check after the extract ran only where
filesize()exists, so on a host withfilesizeindisable_functionsevery entry was accepted unmeasured and a truncated archive (the central directory says 20 bytes, the data holds 10) was installed under a success alert. A small helper,extractedSize(), now reads each extracted file's size with the first function the host leaves enabled:filesize(), elsestat(), elsefile_get_contents(), which the core needs everywhere; a file none of them can read counts as missing. Test: themodule-installprobe (tests/probe.php) run withdisable_functions=filesizeand withfilesize,statover an installed theme and a doctored-size GitHub archive expects the danger alert and the old folder intact (fails on 50df22f: success alert, truncated copy installed). The probe'sredirect()now exits in the module modes, as the real one does, so a failure branch does not run on into the success one.Tests
tests/LocalModulesTest.php, next to the #441 tests:foo.update.tmpleft, danger alert, no success alert (fails on 372 head 52f2c91: success alert, module replaced by the partial copy)foo.update.tmp/from a killed request plus a clean archive:fooholds only the archive's files, no staging folder left (fails on 52f2c91)filesize()(and one that disablesstat()too) still measures the extracted files and refuses a truncated archive (fails on 50df22f)foo.update.tmpand at a remnant name,foo.old.0123abcd.tmp, pointing at a folder outside the module, next to a plain remnant folderfoo.old.89abcdef.tmp/: after the update both links and the remnant folder are gone, the outside file is intact, nothing was extracted into it, and the module is updated (fails with a trailing slash on the staging path, without the remnant sweep, withGLOB_MARKon its glob, or with a sweep that follows a link: the outside file is deleted)foowhoselocked/subfolder cannot be emptied (0555), or cannot even be opened (0000), updated from afoo/archive and from afoo-master/archive: success alert,fooholds only the new copy, the remnant stays in afoo.old.<8 hex>.tmp/locked(each case fails on 3f2c974:Exception: Theme or plugin not installed, orUnexpectedValueExceptionfromDirectoryIteratorfor 0000; through the probe, exit 255 with the module half-deleted). Skipped when the user can write into a read-only folder (root).foofrom afoo/archive, a locked 0555 folder uploaded intofooagain before each: both land with a success alert,fooholds the new copy each time, and each upload stays in its own remnant (fails on 87d98f5, where the aside name was fixed: the second rename aside met the first remnant, the delete-first fallback stopped at the locked folder, and the second update threwException: Theme or plugin not installed). Skipped as root.foothat cannot be renamed aside (the stubbedtempPath()returns a path in a folder that does not exist, so the rename is refused on every platform, as root too) or gets no aside name (the stub throws, asrandom_bytes()does with no source of randomness), updated from afoo/archive and from afoo-master/archive: the danger alert "Could not move the installed version aside. Nothing was changed. Check that themes/foo is not locked or in use, then try again.", no success alert,foobyte-identical, nofoo.update.tmp,foo-masterorfoo.old.*left. Each of the four cases fails on e4f75c4: a refused rename took the delete-first fallback and ended in a success alert over the deleted folder, and the throwingtempPath()escaped as an uncaughtException; the throwing cases also fail with thetry/catchremoved.foowhose rename aside is refused across devices (the stubbedtempPath()returns a path in/dev, a filesystem of its own on Linux and macOS, sorename()gets a realEXDEVand PHP's own message), updated from afoo/archive and from afoo-master/archive: success alert, no danger alert,fooholds only the new copy, no staging, extracted or aside folder left (fails on 9a41318 with the danger alert "Could not move the installed version aside. Nothing was changed.", on macOS and in the Docker image; also fails with the delete left to a folder that was not installed). The test above fails if every refusal takes this path, and both fail if the match reads a path in the message instead of its reason. Skipped on Windows.foowhoselocked/subfolder cannot be emptied (0555, from afoo/and from afoo-master/archive) or opened (0000, from afoo/archive): the danger alert namingthemes/fooand ending "and that the web server can delete everything in it, then try again.", no success alert,fooholdingtheme.phpandlocked/keep.txtas before and nothing else, no staging, extracted or aside folder left. Each case fails on f28f4c6: the 0555 cases withException: Theme or plugin not installed,foostripped tolocked/keep.txtand the new copy stranded infoo.update.tmp/orfoo-master/; the 0000 case withUnexpectedValueExceptionfromDirectoryIteratorandfoo.update.tmp/stranded. It also fails with the check removed, made shallow (no look into subfolders) or without itstry/catch, and with the tail of the alert dropped; the cross-device test above fails if the check always refuses. Skipped as root and on Windows.foo(theme.php,css/style.css) whoselocked/subfolder has write but no search permission (0666), socanEmpty()says yes and the delete stops at it, from afoo/and from afoo-master/archive (theme.php,css/style.css,js/app.js), and from afoo/archive that also carrieslocked/new.txt: the success alert,foo=css,js,locked,theme.phpwith the new content,locked/keep.txtas before and alone, no staging, extracted or aside folder left; no danger alert for the first two, and for the third the one namingthemes/foo. Each case fails on a763bf6 withException: Theme or plugin not installed,foostripped tolocked/keep.txtand the new copy stranded. It also fails with the merge moving nothing, with a failed entry not reported, and with the fallback removed. Skipped as root and on Windows.foowhosecss/stays (a 0666css/locked/stops the delete there, as a mount point would), from afoo-master/archive carryingtheme.phpandcss/fonts/a.woff2, with the new copy'scss/made read-only once extracted (from the stubbedtempPath()), sorename()refuses itsfonts/folder while the file in it can still move, the split a mount point makes: the success alert, no danger alert,foo/css=fonts,lockedwith the new font infonts/. Fails on 8649435 with the partial alert andfonts/left out. Skipped as root and on Windows.mergeInto()called directly (through reflection) over afoowhosecssis a link to a folder outside the module, with a newcss/style.css: it returns true, the link is replaced by a real folder holding the new file, and the outside folder holds only its own file. Fails with the destination-link check removed (the new file is written through the link into the outside folder). Skipped on Windows.foowhosecss/is on a device of its own (a stubbeddeviceOf(); a 0666css/locked/keepscss/in place through the delete, as a mount point does), from afoo/and from afoo-master/archive (theme.php,css/style.css,css/print.css): the success alert, no danger alert,css/the same folder as before (its inode unchanged) holdinglocked,print.cssandstyle.csswith the new content, no staging, extracted or aside folder left. Fails on f25ea5a with only thedeviceOf()seam added: the rename aside tookcss/along, so thecss/in place is another folder and the remnant holds the old one. Skipped as root and on Windows.hdiutil,newfs_hfs,diskutil mount) mounted atthemes/foo/css, through the real action from afoo/and from afoo-master/archive: the same, and the volume still mounted atcss/; thenmergeInto()called directly with an undeletable link (chflags -h uchg) on the volume pointing at a file outside the module: it returns false (in the action, the partial alert), the link and the outside file as they were. Fails on f25ea5a (the mount moved into the remnant, emptied) and with the new link skip removed (PHP's copy across the mount wrote through the link). Skipped wherehdiutilis absent (CI).fooon a device of its own, everything in it on that device too (a stubbeddeviceOf(); a 0666locked/keepsfooin place through the delete, as a mount point does), from afoo/and from afoo-master/archive (theme.php,css/style.css,css/print.css): the success alert, no danger alert,foothe same folder as before (its inode unchanged) holdingcss,lockedandtheme.phpwith the new content, no staging, extracted or aside folder left; then with a read-onlycss/the danger alert beginning "Could not update themes/foo: it cannot be written. Nothing was changed." (no "aside" in it), no success alert,fooas it was. Fails on d7860ba (the rename aside tookfooalong, so thefooin place is another folder), with the parent's device left unread, and with the refusal's old wording. Skipped as root and on Windows.holdsMount()called directly with a stubbedmountInfo(): a mount point under the module and one on the module folder itself count;/,/proc, the parent folder, a sibling sharing the name's prefix (foobar) and a folder under that sibling do not; a site path holding a space and a backslash before040(written\040and\134040) is decoded once, never twice. Then the update with a bind mount listed atthemes/foo/css(a 0666css/locked/keepscss/in place through the delete), from afoo/and from afoo-master/archive: the success alert,css/the same folder holding the new file. Fails with the mount list left unread, with the escapes left undecoded, and with a decode that undoes\134before\040. On d7860ba the seam does not exist. Skipped as root and on Windows..../site[1]/and a sibling.../site1/, each with a remnant offooand a stale database temp file: an update insite[1]clears only its own remnant, and a save there sweeps only its own temp file (fails with either escape removed: the own leftover stays and the sibling's is removed).The immutable shape itself was run through the
module-installprobe withchflags uchg themes/fooon macOS (fooholdingtheme.php,css/,js/,images/), for both archive shapes. e4f75c4: exit 255,Theme or plugin not installed,foostripped totheme.php, the new copy stranded infoo.update.tmp/orfoo-master/. This head: the danger alert,foomd5-identical, nothing left beside it. It is not in the suite: it needschflagsorchattrand a non-root user.The Docker case was run through the same probe in the project image (
ghcr.io/robiso/wondercms:3.7.0, PHP 8.4.27, overlayfs,redirect_dir=N), withindex.phpandtests/probe.phpcopied in, updating the bundledthemes/skyfrom asky/and from asky-master/archive. A barerename()ofthemes/skythere is refused with "Invalid cross-device link". 9a41318: the danger alert, Sky untouched, so Sky could never be updated. This head: "Successfully installed/updated sky." for both shapes,skyholding only the new copy, nothing left beside it. With a part planted in the image's Sky first (PHP runs aswww-data), updating from asky/archive (thesky-master/arm the same unless noted), each run from a fresh container:themes/skylocked/keep.txt, folder owned by root, 0755locked/kept (own-name arm); GitHub arm: exception, Sky stripped tolocked/,sky-master/strandedcustom/(--tmpfs)sky.update.tmp/stranded, the same on every retrycache/owned by root, 1777, holding root's filecache/rootfilecache/rootfilekept; both armsnoexec/owned by www-data, 0666 (write, no search)noexec/fkept (own-name); GitHub arm: exceptionnoexec/fnoexec/fkeptnoexec/xxnot writtenthemes/sky; theme.php and css new,noexec/fkept,xnot placedThe rollback has no input that reaches it (the rename aside has just shown the folder is writable); it was checked with a scratch change that makes the rename into place fail, for both archive shapes and with a locked subfolder: danger alert, the installed folder back whole, no
.old.*.tmp, staging or-masterfolder left.The other #441 tests (and, merged with 372, the #442 tests) and the install and symlink tests are unchanged and green, under PHPUnit 9.6 too. PHP 7.4 syntax; PHPUnit 9.6 assertions.
No VERSION bump.