Skip to content

fix(core): addPackage returns result of setPackageMeta when adding/updating package#270

Open
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Ibochkarev:fix/add-package-return-setpackagemeta-result
Open

fix(core): addPackage returns result of setPackageMeta when adding/updating package#270
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Ibochkarev:fix/add-package-return-setpackagemeta-result

Conversation

@Ibochkarev
Copy link
Contributor

addPackage() now returns the result of setPackageMeta() when adding or updating a package, so callers get false when metadata load fails (e.g. missing or empty metadata.{dbtype}.php). When the package is already loaded with the same path/prefix, addPackage() still returns true.

Previously addPackage() always set $added = true after calling setPackageMeta(), so callers could not detect metadata load failure. setPackage() already relies on addPackage()'s return value to avoid changing the current package on failure.

We assign $added from the single setPackageMeta() call in the new/updated branch and use else { $added = true } when the package is already registered with the same path/prefix, so setPackageMeta() is not called twice.

Fixes #145

…dating package

addPackage() now assigns $added from setPackageMeta() when adding or
updating a package, so callers get false when metadata load fails
(e.g. missing or empty metadata.{dbtype}.php). When the package is
already loaded with the same path/prefix, $added remains true.

Resolves modxcms#145
@Ibochkarev Ibochkarev marked this pull request as ready for review March 11, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xPDO->addPackage returns true even if xPDO->setPackageMeta fails

1 participant