Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinxapi.php breaks in php 8.2 #1437

Closed
yitan800 opened this issue Sep 11, 2023 · 5 comments
Closed

sphinxapi.php breaks in php 8.2 #1437

yitan800 opened this issue Sep 11, 2023 · 5 comments
Assignees
Labels

Comments

@yitan800
Copy link

Describe the bug
A clear and concise description of what the bug is.
php8.2 is installed by default under ubuntu 22.04. The latest sphinxapi.php breaks in a number of places. The most significant errors are due to the fact that @ Error Suppression operator does not silent fatal errors in php8.2. They are related to how the socket is connected, close and etc.

To Reproduce
Steps to reproduce the behavior:

  1. Given a query and index, calling the function query defined in sphinxapi.php will return a number of errors.

Expected behavior
A clear and concise description of what you expected to happen.
Given a query and index, calling the function query defined in sphinxapi.php will return results without any errors.

Describe the environment:

  • Manticore Search version (top line in output of bin/searchd -v or bin/indexer -v): e.g. 3.5.0 1d34c49@200722 release
  • OS version (uname -a if on a Unix-like system):

OS: ubuntu 22.04
PHP: 8.2.10
Messages from log files:
Messages from searchd.log and query.log (if applicable).

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in sphinxapi.php:1101 Stack trace: #0 sphinxapi.php(1064): SphinxClient->AddQuery() #1 SphinxClient->Query() #2 {main} thrown in sphinxapi.php on line 1101

Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, null given in sphinxapi.php:518 Stack trace: #0 sphinxapi.php(518): fclose() #1 [internal function]: SphinxClient->__destruct() #2 {main} thrown in sphinxapi.php on line 518

Additional context
Add any other context about the problem here.
In case you've faced a crash what indextool --check returns.

@yitan800
Copy link
Author

yitan800 commented Oct 1, 2023

May I ask what the status of this issue is at this time? Thanks.

@sanikolaev
Copy link
Collaborator

May I ask what the status of this issue is at this time? Thanks.

No news. Would you like to make a PR with the fixes?

@sanikolaev sanikolaev added the rel::upcoming Upcoming release label Oct 20, 2023
@sanikolaev
Copy link
Collaborator

In Ubuntu 22.04:

root@068a7ed986f9:/# cat /etc/os-release|grep VERSION
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy

apt install php installed PHP 8.1:

root@068a7ed986f9:/# php -v
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)

and this script:

root@068a7ed986f9:/# mysql -P9306 -h0 -e "drop table if exists t; create table t(f text); insert into t values(0, 'abc');"

root@068a7ed986f9:/# cat test.php
<?php
include('/usr/share/manticore/api/sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer('127.0.0.1', 9312);
$res = $cl->Query('abc', 't');
print_r($res);

didn't fail. It also didn't fail with PHP 8.2:

root@068a7ed986f9:/# php -v
PHP 8.2.11 (cli) (built: Oct  6 2023 09:47:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies
root@068a7ed986f9:/# php test.php
Array
(
    [error] =>
    [warning] =>
    [status] => 0
    [fields] => Array
        (
            [0] => f
        )

    [attrs] => Array
        (
            [f] => 7
        )

    [matches] => Array
        (
            [4758168996388274178] => Array
                (
                    [weight] => 1500
                    [attrs] => Array
                        (
                            [f] => abc
                        )

                )

        )

    [total] => 1
    [total_found] => 1
    [time] => 0.000
    [words] => Array
        (
            [abc] => Array
                (
                    [docs] => 1
                    [hits] => 1
                )

        )

)

@yitan800 please provide more info on how to reproduce the issue.

@sanikolaev sanikolaev added the waiting Waiting for the original poster (in most cases) or something else label Oct 20, 2023
@Nick-S-2018
Copy link
Collaborator

@yitan800
The message Uncaught TypeError: count(): Argument \#1 ($value) must be of type Countable|array, null given occurs because a request property (e.g., search filters) is set to null in place of required array somewhere in your client application. This is an expected behavior, so we would recommend you to check out your application to fix it there.

@sanikolaev
Copy link
Collaborator

I'm closing this issue as it's seems that there's actually no problem and sphinxapi.php works in PHP 8.2.

@yitan800 Feel free to reopen in case you can provide a reproducible example.

@sanikolaev sanikolaev removed the waiting Waiting for the original poster (in most cases) or something else label Dec 29, 2023
@sanikolaev sanikolaev added rel::6.3.0 Released in 6.3.0 and removed rel::upcoming Upcoming release labels May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants