Commit 5d024d0
Fix unautoloadable FacebookAds classes in capi-param-builder (PSR-4 violation breaking php-business-sdk)
Summary:
GitHub issue #36: `FacebookAds\PII_DATA_TYPE` is not autoloadable in 1.3.1, which breaks `facebook/php-business-sdk` 25.0.2 — `UserData::normalize()` calls `FacebookAds\PII_DATA_TYPE::EMAIL`, and any server-side Conversions API event fatals with `Class "FacebookAds\PII_DATA_TYPE" not found`.
Root cause: the package's only autoload rule is `psr-4: { "FacebookAds\\": "src/" }`, but `PII_DATA_TYPE` (and in fact all 15 classes under `src/model/`, `src/util/`, `src/piiUtil/`) declare the flat `namespace FacebookAds;` while living in subdirectories. Under PSR-4, `FacebookAds\PII_DATA_TYPE` must resolve to `src/PII_DATA_TYPE.php`; Composer never looks in `src/model/Constants.php`, so `class_exists('FacebookAds\PII_DATA_TYPE')` returns false. The package itself only works today via manual `require_once` chains, but a downstream consumer that references the class through Composer autoloading (like the SDK) fatals.
Fix: add a `classmap` autoload entry for the three subdirectories alongside the existing PSR-4 map. Composer's classmap maps a class to its file by scanning declarations regardless of filename or directory, so `FacebookAds\PII_DATA_TYPE` and the other 14 subdirectory classes become autoloadable while every fully-qualified class name stays exactly as-is (important: the SDK depends on the flat `FacebookAds\PII_DATA_TYPE` FQN, so renaming/re-namespacing is not an option). This is the maintainer-suggested fix from the issue and requires no file moves or namespace changes. Also bumped the package version 1.3.1 -> 1.3.2 so the fix ships as a new release.
___
Differential Revision: D112249764
fbshipit-source-id: 7f5b758a5f93683daa182bc1fd7aecfec869233e1 parent f334b26 commit 5d024d0
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
0 commit comments