Skip to content

Fix/php82 open issues - #60

Merged
airmoi merged 20 commits into
masterfrom
fix/php82-open-issues
Oct 23, 2026
Merged

airmoi merged 20 commits into
masterfrom
fix/php82-open-issues

Conversation

@airmoi

@airmoi airmoi commented Oct 23, 2026

Copy link
Copy Markdown
Owner

PHP 8.2+ only, fix all open issues (3.1.0)

Drops PHP 5/7 support ("php": "^8.2"), fixes every open issue, and migrates the tests to PHPUnit 10 with a new offline suite. It has no deprecation notices from PHP 8.2 through 8.5.

Fixes #19, fixes #35, fixes #36, fixes #42, fixes #48, fixes #50, fixes #52, fixes #54, fixes #55, fixes #56, fixes #57
Supersedes #59 (thanks @precursorca)

Changes (one commit per issue)

Issue Fix
#57 / #59 Removed curl_close() and xml_parser_free() (deprecated in 8.5). XML handlers are now first-class callables instead of xml_set_object() plus method names (deprecated in 8.4). The exact message quoted in #57 comes from airmoi/yii2-fmconnector (FileMakerActiveRecord::findAll()), so it needs a separate fix there.
#52 Replaced utf8_encode/utf8_decode with mb_convert_encoding (new toInputCharset() helper).
#48 CWP params are cast to string before url-encoding (new buildCwpQuery()). Also fixed a TypeError (array_merge(null, …)) on Data API -new queries that have no field data.
#54 The Data API auth headers now use Basic/Bearer instead of lowercase.
#56 The token is now saved (session handler or PHP session) and reused. The destructor had an operator-precedence bug and now only logs out tokens that couldn't be saved, catching any Throwable. __set() ignored setters that take a parameter, so setSessionHandler(), setCache() and $fm->token = null did nothing. Expired tokens are removed from the session when renewed. Added logout() and isTokenPersisted().
#50 Response headers are captured with CURLOPT_HEADERFUNCTION. Redirects (e.g. HTTP→HTTPS) and non-XML responses now give an explicit error with the HTTP status, content type, an excerpt and hints. A BOM or leading whitespace is stripped before parsing.
#42 Couldn't reproduce: nothing is logged without a logger, and messages are filtered by level. Hardening: logLevel is compared as an integer, the Data API password and session token are masked in logs, profiling keys and getLastRequestedUrl(), and container binaries are no longer dumped at DEBUG level.
#35 Record::commitAdd() passes useRawData so dates aren't converted twice.
#19 Edit commands, and commits of existing records, only prevalidate the fields they modify.
#36 New opt-in property skipAutoEnteredValidation: when on, prevalidation skips empty auto-entered fields.
#55 README: requirements, hosting (Linux/cPanel), Data API tokens, logging, troubleshooting, changelog.

Also:

  • Fixes for bugs found running the integration suite against a real server:
    • Field::hasValidationRule() always returned false.
    • Field::check*Format() passed null to preg_match().
    • FileMakerValidationException::getMessage() started with a stray "Unknown error" line.
    • getErrorString(null) triggered a PHP 8.5 deprecation.
    • Cached layouts kept a reference to the FileMaker instance that loaded them, so records could be committed through another instance (other engine, settings and credentials). Layouts are now cached per engine and rebound to the requesting instance, and they no longer serialize the instance and its credentials into external caches.
  • Fixed missing leading zeros in DateFormat::convertWithWildCards(); the existing DateFormatTest was failing.
  • apiVersion is now 3.1.0. Added the ext-mbstring requirement. Dev dependencies are now PHPUnit 10.5 and Psalm 6.

Tests

  • Server-dependent tests moved to tests/integration and migrated to PHPUnit 10. Fixed in passing: phpunit.sample.xml was invalid XML, relative paths broke when the tests moved, $GLOBALS['ENGINE'] was never defined, and one test hardcoded the database name.
  • New offline suite tests/unit (64 tests) using a FakeFileMaker transport, with regression tests for each fix.
  • phpunit.xml.dist fails on deprecations, notices and warnings.
  • Integration settings can be passed as FM_HOST, FM_DATABASE, FM_USER, FM_PASSWORD and FM_USE_DATA_API environment variables, which override phpunit.xml.
  • Test database: tests/filemaker-test.fmp12 is replaced by tests/php-api-test.fmp12.zip. It has been updated with the fields, relationships and Data API access the integration suite needs. Unzipped tests/*.fmp12 files are gitignored.

CI (.github/workflows/tests.yml)

  • Runs on pull requests, pushes to master, and manual triggers. A new push to the same PR cancels the run in progress.
  • Unit: validates composer.json, syntax-checks every PHP file, and runs the unit suite on PHP 8.2, 8.3, 8.4 and 8.5.
  • Integration: runs on PHP 8.2 and 8.5 for both CWP and Data API against the hosted test database.
    • The jobs run one at a time because they share the database.
    • They're skipped for PRs from forks, which don't receive secrets.
    • They're also skipped, with a warning, when the repository isn't configured.
  • Required settings: the FM_HOST and FM_DATABASE repository variables, and the FM_USER and FM_PASSWORD repository secrets.

Verification

Behavior changes to note

  • Data API tokens are now stored in $_SESSION when a PHP session is available, as the README already described. Before, they were never stored.
  • setSessionHandler() and setCache() now actually take effect.
  • Cached layouts are bound to the instance that requests them, and the cache key includes the engine.
  • Redirects are reported as errors rather than followed: cURL drops the auth header when switching from HTTP to HTTPS. Use an https:// hostspec.

airmoi and others added 20 commits October 23, 2026 11:19
Drop PHP 5/7 support. Add ext-mbstring requirement, upgrade dev
dependencies to PHPUnit 10 and Psalm 6.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Day, month, hour, minute and second tokens (d, m, h, H, i, s) were
rendered without leading zeros.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move server dependent tests to tests/integration
- Add offline tests/unit suite with a FakeFileMaker transport and
  response fixtures
- Add phpunit.xml.dist failing on deprecations/notices/warnings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Drop curl_close() calls (no-op since PHP 8.0, deprecated in 8.5)
- Drop xml_parser_free() calls (deprecated in 8.5)
- Use first-class callables for XML handlers instead of
  xml_set_object() + method names (deprecated in 8.4)

Fixes #57
Supersedes #59

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use mb_convert_encoding() through new toInputCharset() and existing
toOutputCharset() helpers. Arrays sent to the Data API are now JSON
encoded before charset conversion.

Fixes #52

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Cast CWP parameters to string before url encoding (extracted to
  buildCwpQuery())
- Initialize Data API body for -new queries, array_merge(null, ...)
  threw a TypeError when no field data was provided

Fixes #48

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FileMaker Data API rejected the lowercase schemes with "Authorization
header missing 'Basic' or 'Bearer'". The composer constraint now
also allows PHP 8 (see previous commit).

Fixes #54

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tokens were never reused nor released, exhausting FileMaker Server
connections (error 812):
- getToken() now saves the token through setToken() so it is reused
  by next requests (session handler or active PHP session)
- __destruct() had an operator precedence bug; it now only logs out
  tokens that could not be saved, reads raw properties and ignores any
  Throwable during shutdown
- __set() only forwarded to setters without parameter, so
  setSessionHandler(), setCache() and $fm->token = null were no-ops
- Expired tokens are removed from the session when renewed, logout
  always forgets the token
- Login/transport errors are returned instead of being used as token
- Add logout() and isTokenPersisted()

Fixes #56

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
"XML error: Not well-formed (invalid token) at line 1" was raised
whenever FileMaker Server answered with something else than XML
(HTTP to HTTPS redirect, disabled XML publishing page...).
- Collect response headers with CURLOPT_HEADERFUNCTION instead of
  mixing them with the body
- Report redirects with their target location
- Report non XML responses with HTTP status, content type, an excerpt
  and hints (hostspec, XML Web Publishing, Data API)
- Strip BOM and leading whitespaces before parsing
- Don't call setcookie() once headers are sent

Fixes #50

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Compare logLevel as integer, allow false to disable logging
- Mask Data API password and session token in logs, profiling keys
  and getLastRequestedUrl()
- Log container data size instead of the raw binary at debug level
- Test that messages above logLevel are never forwarded to the logger

Fixes #42

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record::setField() already converts dates from the dateFormat
property, Record::commitAdd() now passes useRawData to the Add command
like commitEdit() does.

Fixes #35

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Edit commands (and Record::commit() on existing records) failed
prevalidation when required fields were not part of the update.

Fixes #19

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When enabled, prevalidation ignores auto-entered fields (ie: serial
primary keys) left empty, FileMaker Server populates them on creation.
Provided values are still validated. Disabled by default.

Fixes #36

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document PHP 8.2+ requirements and hosting (Linux/cPanel), Data API
token handling, prevalidation options, logging, troubleshooting and
changelog.

Fixes #55

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Field::check*Format() passed null to preg_match() (PHP 8.1
  deprecation, see #48)
- FileMakerValidationException::getMessage() started with a generic
  'Unknown error' line before the validation errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- phpunit.sample.xml contained '--' inside an XML comment (invalid XML)
- Fix relative paths of moved tests, declare dynamic properties
- Derive engine from USE_DATA_API ($GLOBALS['ENGINE'] was never
  defined), fix an assignment used as condition

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- hasValidationRule() used isset() on the integer validation mask and
  always returned false; check parsed validation rules instead (the
  mask can't be used either: rule constants are not powers of two)
- getErrorString(null) used null as array offset (PHP 8.5 deprecation)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Layouts were cached statically with a reference to the FileMaker
instance that loaded them: records created from a cached layout were
committed through another instance (other engine, settings and
credentials). Found running the integration suite in Data API mode.
- Cache key includes the engine (CWP and Data API metadata differ)
- getLayout() returns a copy bound to the current instance when the
  cached layout belongs to another one or comes from an external cache
- Layout/RelatedSet no longer serialize the FileMaker instance, which
  leaked credentials into external caches (now effective since
  setCache() is fixed)
- Layout::loadExtendedInfo() cached under a wrong key

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- tests/filemaker-test.fmp12 replaced by tests/php-api-test.fmp12.zip,
  updated with the fields, relationships and Data API access required
  by the integration suite
- Ignore extracted tests/*.fmp12
- Use DB_FILE instead of a hardcoded database name in tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Unit tests and lint on PHP 8.2 to 8.5
- Integration tests on PHP 8.2/8.5 for CWP and Data API against the
  hosted test database, configured with FM_HOST/FM_DATABASE variables
  and FM_USER/FM_PASSWORD secrets; jobs run sequentially since they
  share the database, skipped for forks
- tests/bootstrap.php maps FM_* environment variables to test settings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@airmoi
airmoi merged commit a51f663 into master Oct 23, 2026
8 checks passed
@airmoi
airmoi deleted the fix/php82-open-issues branch October 23, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment