Skip to content

Make HTML_QuickForm_file rule methods static for PHP 8#150

Merged
shannah merged 1 commit into
masterfrom
claude/fix-xataface-issue-147-qx6df
May 18, 2026
Merged

Make HTML_QuickForm_file rule methods static for PHP 8#150
shannah merged 1 commit into
masterfrom
claude/fix-xataface-issue-147-qx6df

Conversation

@shannah

@shannah shannah commented May 17, 2026

Copy link
Copy Markdown
Owner

The file element registers four validation rules as callbacks via
HTML_QuickForm::registerRule('callback', ...), which stores them as
[class_name, method_name] pairs and later invokes them with
call_user_func. The methods (_ruleIsUploadedFile, _ruleCheckMaxFileSize,
_ruleCheckMimeType, _ruleCheckFileName) were declared as instance
methods even though they never reference $this. Under PHP 8 the
"call non-static method statically" pattern throws TypeError, aborting
file/blob uploads with:

Argument #1 ($callback) must be a valid callback, non-static method
HTML_QuickForm_file::_ruleCheckMaxFileSize() cannot be called statically

Mark all four rule methods static so the registered callbacks remain
valid under PHP 8. Existing $this-> call sites (e.g. isUploadedFile)
continue to work because static methods can be invoked via an instance.

Fixes #147

https://claude.ai/code/session_014nJbXsY9TdG5PXE2kBHRuV

The file element registers four validation rules as callbacks via
HTML_QuickForm::registerRule('callback', ...), which stores them as
[class_name, method_name] pairs and later invokes them with
call_user_func. The methods (_ruleIsUploadedFile, _ruleCheckMaxFileSize,
_ruleCheckMimeType, _ruleCheckFileName) were declared as instance
methods even though they never reference $this. Under PHP 8 the
"call non-static method statically" pattern throws TypeError, aborting
file/blob uploads with:

  Argument #1 ($callback) must be a valid callback, non-static method
  HTML_QuickForm_file::_ruleCheckMaxFileSize() cannot be called statically

Mark all four rule methods static so the registered callbacks remain
valid under PHP 8. Existing $this-> call sites (e.g. isUploadedFile)
continue to work because static methods can be invoked via an instance.

Fixes #147

https://claude.ai/code/session_014nJbXsY9TdG5PXE2kBHRuV
@airdrummer

Copy link
Copy Markdown
Contributor

i d/l'd both xataface/lib/HTML/QuickForm/file.php & hiddenselect.php, uploaded to hoadbbut still no joy-/

Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method HTML_QuickForm_file::_ruleCheckMaxFileSize() cannot be called statically in /home/cardin55/public_html/hoaDB/xataface-29apr26/lib/HTML/QuickForm/Rule/Callback.php:66 Stack trace: #0 /home/cardin55/public_html/hoaDB/xataface-29apr26/lib/HTML/QuickForm/RuleRegistry.php(148): HTML_QuickForm_Rule_Callback->validate(Array, '12000000') #1 /home/cardin55/public_html/hoaDB/xataface-29apr26/lib/HTML/QuickForm.php(1536): HTML_QuickForm_RuleRegistry->validate('maxfilesize', Array, '12000000', true) #2 /home/cardin55/public_html/hoaDB/xataface-29apr26/Dataface/ShortRelatedRecordForm.php(739): HTML_QuickForm->validate() #3 /home/cardin55/public_html/hoaDB/xataface-29apr26/actions/new_related_record.php(90): Dataface_ShortRelatedRecordForm->validate() #4 /home/cardin55/public_html/hoaDB/xataface-29apr26/Dataface/Application.php(3723): dataface_actions_new_related_record->handle(Array) #5 /home/cardin55/public_html/hoaDB/xataface-29apr26/Dataface/Application.php(3866): Dataface_Application->handleRequest() #6 /home/cardin55/public_html/hoaDB/xataface-29apr26/Dataface/Application.php(3751): Dataface_Application->_display(false, false) #7 /home/cardin55/public_html/hoaDB/index.php(12): Dataface_Application->display() #8 {main} thrown in /home/cardin55/public_html/hoaDB/xataface-29apr26/lib/HTML/QuickForm/Rule/Callback.php on line 66

@shannah shannah merged commit 4720c01 into master May 18, 2026
12 checks passed
@shannah shannah deleted the claude/fix-xataface-issue-147-qx6df branch May 18, 2026 12:02
@shannah

shannah commented May 18, 2026

Copy link
Copy Markdown
Owner Author

@airdrummer I can't reproduce on a test app. That error readout suggests that this fix wasn't applied. If you're still getting an error, please post in a new issue.

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.

re: file/blob upload fatal error #145

3 participants