Skip to content

Fix PHP 8.5 warnings and add GitHub login sample - #1443

Open
jackfong123 wants to merge 2 commits into
aisingapore:masterfrom
jackfong123:fix/php85-tagui-compat
Open

jackfong123 wants to merge 2 commits into
aisingapore:masterfrom
jackfong123:fix/php85-tagui-compat

Conversation

@jackfong123

Copy link
Copy Markdown

Summary

This PR fixes PHP 8.5 compatibility issues that were blocking or polluting TagUI browser automation runs, and adds
a small GitHub login navigation sample flow for verification.

Changes

  • Update src/tagui_parse.php to pass an explicit escape argument to fgetcsv()

    • This avoids PHP 8.5 deprecation warnings during flow parsing
    • It also prevents TagUI from aborting early when those warnings are written into the flow log
  • Update src/ws/Base.php for PHP 8.5 compatibility

    • Replace deprecated (boolean) casts with (bool)
    • Replace deprecated (integer) casts with (int)
    • Declare the shared $options property in the base class to avoid dynamic property warnings from
      WebSocket\Client
  • Add flows/samples/github_login.tag

    • Opens GitHub homepage
    • Clicks the visible header sign-in entry
    • Lands on the GitHub login page

Co-authored-by: TRAE CLI <traecli@bytedance.com>
@kensoh

kensoh commented Sep 13, 2026

Copy link
Copy Markdown
Member

Thanks @jackfong123 ! I'm not sure if above change would be backward compatible with older or existing PHP versions of existing users. Do you have comments on that?

Hi @marcelocecin above is a proposed change for PHP compatibility 8.5. Would you be the right person to ask if the change would break backward compatibility for existing users using older PHP?

@marcelocecin

Copy link
Copy Markdown

Hi @kensoh, I tested this PR on macOS against PHP 5.6, 7.0, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5 (Docker), plus real Chrome runs on PHP 8.5.9.

Backward compatible: yes. The explicit fgetcsv() arguments are the existing defaults (the $escape param exists since PHP 5.3), (bool)/(int) are canonical casts in every version, and declaring $options in Base is harmless. The generated flow .js is byte-identical to master on all 9 versions, and a WebSocket echo test (7/16/64-bit payload lengths) passes on all of them.

But it's incomplete: transpose.php (fgetcsv + fputcsv) and translate.php (fgetcsv) have the same deprecation, so on PHP ≥ 8.4 running a flow with a datatable (tagui flow.tag data.csv) or with a non-English tagui_language still ends with ERROR - automation aborted due to above. With the same fix applied to those two files, datatable runs complete on 8.5 and output is identical from 5.6 to 8.5 (fputcsv's $escape param exists since 5.5.4). Also note the fgetcsv deprecation starts on PHP 8.4, not 8.5.

Suggest @jackfong123 add those two files and drop flows/samples/github_login.tag, which is unrelated and depends on GitHub's markup.

@marcelocecin

Copy link
Copy Markdown

Follow-up: I also ran full end-to-end TagUI runs on Linux (Docker, linux/amd64, headless Chromium, TagUI_Linux PhantomJS/CasperJS) with PHP 7.4, 8.3, 8.4, 8.5 (official php images, no php.ini) and Debian trixie's packaged PHP 8.4 (production php.ini). Flows: a basic flow using tagui_local.csv, a datatable run (flow.tag users.csv) and a Portuguese flow (tagui_language = 'portuguese').

PHP master this PR PR + transpose/translate
7.4 all OK all OK all OK
8.3 basic/datatable OK, non-English aborts same same
8.4 / 8.5 all abort (fgetcsv deprecation) basic OK, datatable + non-English abort basic + datatable OK, non-English aborts
Debian apt 8.4 all OK (deprecations/warnings hidden by production ini) all OK all OK

Linux results match macOS: the PR is backward compatible, and it still needs the same change in transpose.php and translate.php.

One correction to my earlier comment: fixing translate.php's fgetcsv alone is not enough for non-English flows. Since PHP 8.0 they also abort because of two older warnings that have nothing to do with this PR (they happen on master with 8.3 too):

Warning: Undefined array key 2 in src/tagui_parse.php on line 116
Warning: Undefined array key 3 in src/tagui_parse.php on line 116
Warning: Trying to access array offset on false in src/translate.php on line 53

Adding @ in those two spots, like the code already does with @count(...), makes the Portuguese flow pass on 7.4–8.5 too:

-$temp_argv1 = $argv[1]; $temp_argv2 = $argv[2]; $temp_argv3 = $argv[3];
+$temp_argv1 = $argv[1]; $temp_argv2 = @$argv[2]; $temp_argv3 = @$argv[3];
-if ($language_data[$language_count][0] == '') $language_count-=1;} // -1 for EOF
+if (@$language_data[$language_count][0] == '') $language_count-=1;} // -1 for EOF

This could go in this PR or a separate one.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
@jackfong123

Copy link
Copy Markdown
Author

Thanks @marcelocecin for the detailed follow-up. I’ve updated this PR in 585d2e7 to add the missing CSV compatibility fixes intranspose.php and translate.php, and removed flows/samples/github_login.tag as suggested.
I also included the small tagui_parse.php guard from your later note so non-English flows don’t abort on those older warnings.

@marcelocecin

Copy link
Copy Markdown

Hi @kensoh, here is a summary of where this PR stands after @jackfong123's update in 585d2e7, to help you decide.

What the PR does now

  • fgetcsv()/fputcsv() get explicit $escape arguments in tagui_parse.php, transpose.php and translate.php. These are the existing default values, so behaviour doesn't change. It only removes the PHP ≥ 8.4 deprecation that makes TagUI abort with ERROR - automation aborted due to above.
  • src/ws/Base.php: (boolean)/(integer)(bool)/(int), and $options is declared in the base class (removes the PHP 8.5 cast deprecations and the dynamic property warning).
  • @ added to $argv[2]/$argv[3] (tagui_parse.php:116) and $language_data[...] (translate.php:53), in the same style as the existing @count(...). This fixes non-English flows, which already abort on master since PHP 8.0.
  • The unrelated flows/samples/github_login.tag was removed.

All the points from my earlier comments are addressed, and no unpatched fgetcsv/fputcsv/str_getcsv calls or old-style casts remain in src/.

Tests on the final commit (585d2e7)

Backward compatibility, PHP 5.6 / 7.0 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 / 8.4 / 8.5 (official Docker images, error_reporting=-1). Master and the PR were run through the parser (datatable + tagui_local.csv), the parser in Portuguese mode, transpose.php and translate.php:

  • the generated flow .js, transposed CSV and translated flow are identical across all 9 versions and identical to master, apart from the temp folder path embedded in the .js;
  • 0 warnings/deprecations with the PR on every version (master: 2–4 warnings on 5.6–8.3, 184 on 8.4/8.5).
  • All flows in flows/samples were run through the same pre-browser steps the tagui script does (datatable transpose + tagui_parse.php per data set) on all 9 versions. With the PR, every sample parses with no output on every version, and the generated .js for each sample is identical across versions and to master (master aborts on all samples on 8.4/8.5).
    • The one exception is 8_chineseflow.tag, which fails the same way on master and the PR on every version (cannot understand step 输入 ...), because the parser doesn't pick up tagui_language = 'chinese' set inside the flow. This is unrelated to the PR. With chinese set in tagui_config.txt instead, the flow parses with the PR on 5.6–8.5, while master aborts on 8.0+ (Undefined array key 2, then the fgetcsv deprecation on 8.4+).
  • ws/Base.php hasn't changed since the first commit, whose WebSocket echo test (7/16/64-bit payload lengths) passed on all 9 versions.

End-to-end on Linux (Docker linux/amd64, headless Chromium, TagUI_Linux). Flows: basic with tagui_local.csv, datatable with a quoted/comma value, and a Portuguese flow:

PHP master PR (585d2e7)
7.4.33 all OK all OK
8.3.33 Portuguese flow aborts all OK
8.4.25 all abort all OK
8.5.10 all abort all OK
Debian trixie apt 8.4.24 (production php.ini) all OK all OK

The values the flows read and echo are the same as master wherever master works.

End-to-end on macOS with Homebrew PHP 8.5.9 + Chrome: basic, datatable (which goes through transpose.php) and Portuguese flows all finish without aborting.

Suggestions before merging

  1. The title and description are outdated: they still mention the GitHub login sample and only PHP 8.5, and don't mention transpose.php/translate.php. Something like "Fix PHP 8.4+ deprecation warnings that abort flows" would be more accurate.
  2. Squash merge would keep the history clean: the first commit adds the sample and the second removes it, and the first commit's author email isn't linked to a GitHub account.

From my side the change looks safe to merge. It fixes TagUI on PHP 8.4/8.5 (and non-English flows on 8.x) with no behaviour change on older versions.

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.

3 participants