Skip to content

PHP 7.4 reports "Trying to access array offset" messages #37303

Closed

Description

@phil-davis

PHP 7.4 emits messages when code tries to access an array offset on a variable that is not an array. Previous PHP versions did not complain - but actually such code is bad and should be sorted out.

I will check the CI logs of PR #37302 for any of those and report them here.

Edit: checking done - the 2 posts below are what I found.

Activity

  1. phil-davis commented on Apr 24, 2020

    @phil-davis
    ContributorAuthor

    https://drone.owncloud.com/owncloud/core/24446/85/17

    {"reqId":"gjHXY3KH2ySQRqGuqaLe","level":3,"time":"2020-04-24T06:17:37+00:00","remoteAddr":"192.168.16.8","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type bool at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    {"reqId":"gjHXY3KH2ySQRqGuqaLe","level":3,"time":"2020-04-24T06:17:37+00:00","remoteAddr":"192.168.16.8","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type null at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    {"reqId":"gjHXY3KH2ySQRqGuqaLe","level":3,"time":"2020-04-24T06:17:37+00:00","remoteAddr":"192.168.16.8","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type null at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    {"reqId":"g54yEx5JKJfrRrAvDXAa","level":3,"time":"2020-04-24T06:17:58+00:00","remoteAddr":"192.168.16.8","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type bool at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    

    Needs investigating.

    And similar in https://drone.owncloud.com/owncloud/core/24446/127/18

    {"reqId":"SQHYvY6n3kmhO4FPU8OK","level":3,"time":"2020-04-24T06:25:34+00:00","remoteAddr":"192.168.80.9","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type bool at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    {"reqId":"SQHYvY6n3kmhO4FPU8OK","level":3,"time":"2020-04-24T06:25:34+00:00","remoteAddr":"192.168.80.9","user":"user1","app":"PHP","method":"POST","url":"\/ocs\/v1.php\/apps\/files_sharing\/api\/v1\/shares","message":"Trying to access array offset on value of type null at \/drone\/src\/apps\/federatedfilesharing\/lib\/FederatedShareProvider.php#255"}
    

    And https://drone.owncloud.com/owncloud/core/24446/130/18

  2. phil-davis commented on Apr 24, 2020

    @phil-davis
    ContributorAuthor

    In unit tests with sqlite owncloud log: https://drone.owncloud.com/owncloud/core/24446/36/8

    {"reqId":"CPoh13iolBEwfrzbJU3E","level":3,"time":"2020-04-24T06:12:08+00:00","remoteAddr":"","user":"user1_Xxf3GHY9G0y8T","app":"no app in context","method":"--","url":"--","message":"Exception: {\"Exception\":\"PHPUnit\\\\Framework\\\\Error\\\\Notice\",\"Message\":\"Trying to access array offset on value of type null\",\"Code\":8,\"Trace\":\"
    #0 \\\/drone\\\/src\\\/lib\\\/private\\\/Files\\\/Storage\\\/DAV.php(687): PHPUnit\\\\Util\\\\ErrorHandler::handleError()\\n
    #1 \\\/drone\\\/src\\\/lib\\\/private\\\/Files\\\/Storage\\\/DAV.php(175): OC\\\\Files\\\\Storage\\\\DAV->simpleResponse()\\n
    #2 \\\/drone\\\/src\\\/tests\\\/lib\\\/Files\\\/Storage\\\/DavTest.php(165): OC\\\\Files\\\\Storage\\\\DAV->mkdir()\\n
    #3 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestCase.php(1154): Test\\\\Files\\\\Storage\\\\DavTest->testInstantiateWebDavClient()\\n
    #4 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestCase.php(842): PHPUnit\\\\Framework\\\\TestCase->runTest()\\n
    #5 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestResult.php(693): PHPUnit\\\\Framework\\\\TestCase->runBare()\\n
    #6 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestCase.php(796): PHPUnit\\\\Framework\\\\TestResult->run()\\n
    #7 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestSuite.php(746): PHPUnit\\\\Framework\\\\TestCase->run()\\n
    #8 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestSuite.php(746): PHPUnit\\\\Framework\\\\TestSuite->run()\\n
    #9 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/Framework\\\/TestSuite.php(746): PHPUnit\\\\Framework\\\\TestSuite->run()\\n
    #10 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/TextUI\\\/TestRunner.php(652): PHPUnit\\\\Framework\\\\TestSuite->run()\\n
    #11 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/TextUI\\\/Command.php(206): PHPUnit\\\\TextUI\\\\TestRunner->doRun()\\n
    #12 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/src\\\/TextUI\\\/Command.php(162): PHPUnit\\\\TextUI\\\\Command->run()\\n
    #13 \\\/drone\\\/src\\\/lib\\\/composer\\\/phpunit\\\/phpunit\\\/phpunit(61): PHPUnit\\\\TextUI\\\\Command::main()\\n
    #14 {main}\",\"File\":\"\\\/drone\\\/src\\\/lib\\\/private\\\/Files\\\/Storage\\\/DAV.php\",\"Line\":687}"}
    {"reqId":"CPoh13iolBEwfrzbJU3E","level":3,"time":"2020-04-24T06:12:08+00:00","remoteAddr":"","user":"user1_Xxf3GHY9G0y8T","app":"files_external","method":"--","url":"--","message":"Trying to access array offset on value of type null"}
    
    

    And there is similar in unit tests with mariaDB: https://drone.owncloud.com/owncloud/core/24446/37/9

  3. phil-davis commented on Apr 24, 2020

    @phil-davis
    ContributorAuthor

    @VicDeo can you look at these? Or who?

  4. self-assigned this
    on Apr 24, 2020
  5. VicDeo commented on Apr 24, 2020

    @VicDeo
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions