View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0029034 | mantisbt | api soap | public | 2021-09-01 04:22 | 2022-04-13 12:10 |
Reporter | floREN | Assigned To | community | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.25.2 | ||||
Target Version | 2.25.3 | Fixed in Version | 2.25.3 | ||
Summary | 0029034: SOAP call mc_project_get_id_from_name fails when there is no matching project in PHP 7.2 | ||||
Description | Hello, I accountered a problem on a SOAP API call on MantisBT 2.25.2 when looking for project id by the project name. This call fails with a "SYSTEM WARNING" when no project is found with this name. Exact error message : "Error Description: count(): Parameter must be an array or an object that implements Countable" It's caused by calling count() on $this->current_row while $this->current_row is null in DbQuery->value(). This Warning is new in PHP 7.2. (See https://www.php.net/manual/fr/function.count.php#refsect1-function.count-changelog) | ||||
Steps To Reproduce | Here is a script to reproduce (With PHP 7.2 and PHP Soap) : <?php Which returns : PHP Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Error Type: SYSTEM WARNING, | ||||
Additional Information | I patched core/classes/DbQuery to check for nullity of $this->current_row. It may be sufficient. | ||||
Tags | No tags attached. | ||||
Attached Files | DbQuery.patch (413 bytes)
@@ -857,7 +857,8 @@ class DbQuery { $this->fetch(); } if( is_numeric( $p_index_or_name ) ) { - if( count( $this->current_row ) > $p_index_or_name ) { + if( $this->current_row != null && count( $this->current_row ) > $p_index_or_name ) { # get the element at that numerical position $t_keys = array_keys( $this->current_row ); $t_value = $this->current_row[$t_keys[$p_index_or_name]]; | ||||
Thanks for the bug report and the patch. Is there any chance you could resubmit your proposed fix as a pull request on Github ? It makes the review and merge process easier for us. |
|
I just did it : https://github.com/mantisbt/mantisbt/pull/1779 Is it OK for you ? |
|
Perfect, thanks ! |
|
MantisBT: master-2.25 52b84403 2021-09-01 07:55 fbruneau Committer: dregad Details Diff |
Fix PHP warning when calling count() on bool value PHP Warning: Uncaught TypeError: count(): Argument 0000001 ($value) must be of type Countable|array, bool given in DbQuery.class.php:860 Occurs when calling DbQuery::value() on a query that executes successfully but does not return any rows. Fixes 0029034, PR https://github.com/mantisbt/mantisbt/pull/1779 Signed-off-by: Damien Regad <dregad@mantisbt.org> (cherry picked from commit 00626687cdfc64dad798d61c8036e6199c0efc0b) |
Affected Issues 0029034 |
|
mod - core/classes/DbQuery.class.php | Diff File | ||
MantisBT: master 00626687 2021-09-01 07:55 fbruneau Committer: dregad Details Diff |
Fix PHP warning when calling count() on bool value PHP Warning: Uncaught TypeError: count(): Argument 0000001 ($value) must be of type Countable|array, bool given in DbQuery.class.php:860 Occurs when calling DbQuery::value() on a query that executes successfully but does not return any rows. Fixes 0029034, PR https://github.com/mantisbt/mantisbt/pull/1779 Signed-off-by: Damien Regad <dregad@mantisbt.org> |
Affected Issues 0029034 |
|
mod - core/classes/DbQuery.class.php | Diff File |