[Draft][Bug] Undefined constant.
- Dominant language
- C
- Stars
- 1.6k
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
I'm still studying this issue, and I can't reproduce the error in a simple code. The error only occurs in the production project. Once I reproduce the error, I will update the question or even delete it.
```php
use parallel\Future;
use parallel\Runtime;
class Flow
{
protected Runtime $runtime;
function exec(\Closure $callback, array $args = []): Task
{
// some code...
$wrapTask = static function (\Closure $task, string $taskId, array $args) {
/** @var (null|bool|int|float|string|\Closure|mixed[])[] $args */
try {
var_dump([
\Inilim\IPDO\IPDO::FETCH_IPDO_RESULT, // int(0) - value of the constant is correct
\defined('\Inilim\IPDO\IPDO::FETCH_IPDO_RESULT'), // bool(false) - first bug
]);
\FLOW_TASK_REP->worked($taskId); // throw exception... second bug is related to the first bug, I think
// "FLOW_TASK_REP" - this constant was defined in the previous task.
$result = Other::timedMsCall(static function () use ($task, $args) {
try {
return $task(...$args);
} catch (\Throwable) {
return null;
}
});
\FLOW_TASK_REP->success($taskId, \json_encode([
'value' => $result['result'],
'time' => $result['time'],
]));
} catch (\Throwable $e) {
VD::dde([
$e->getMessage(), // "Undefined constant Inilim\IPDO\IPDO::FETCH_IPDO_RESULT"
$e->getFile(),
$e->getLine(),
]);
}
};
$this->futures[$task->id] = $this->runtime->run($wrapTask, [$callback, $task->id, $args]);
return $task;
}
}
```
Inside the "worked" method, there is a nested method with an argument that has a default value for a constant.
```php
use Inilim\IPDO\IPDO;
// some code...
protected function internalMethod(
\Closure $callback,
string $sql,
array $values = [],
int $fetch = IPDO::FETCH_IPDO_RESULT
) {...}
```
**PHP**
```
PHP 8.4.9 (cli) (built: Jul 1 2025 15:27:25) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.9, Copyright (c) Zend Technologies
parallel version => 1.2.11
opcache - off
```
**OS**
`Windows 10 Pro`
Contributor guide
Research direction
Start by reducing the production-only failure around Flow::exec, parallel\Runtime, and the nested internalMethod default argument using PHP 8.4.9 and parallel 1.2.11. Compare the constant access and defined() behavior inside the runtime, then document a reproducible case and the conditions required to resolve both undefined-constant errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100