cloudflare / Cloudflare-WordPress

A Cloudflare plugin for WordPress
https://www.cloudflare.com/wordpress/
BSD 3-Clause "New" or "Revised" License
216 stars 83 forks source link

4.8.3: `Notice: Undefined index: value` in CF\WordPress\Hooks::pageRuleContains at line 470 #465

Closed lkraav closed 2 years ago

lkraav commented 2 years ago

Confirmation

WordPress version

5.9.2

Cloudflare-WordPress version

4.8.3

PHP version

7.4.28

Expected result

Error-free operation with cache purge.

Actual result

Traceback https://sentry.io/share/issue/1583084bf8524d1a9feafcfbbbf4824e/

Some page rule doesn't seem to have a value for if ($action["id"] == $key && $action["value"] == $value) conditional?

Steps to reproduce

This triggers during block editor post updates, for example.

/wp-admin/post.php?_locale=user&action=edit&meta-box-loader=1&meta-box-loader-nonce=a3fdacba87&post=57454

Additional factoids

No response

References

No response

jacobbednarz commented 2 years ago

are you able to query all your page rules and drop the response here using https://api.cloudflare.com/#page-rules-for-a-zone-list-page-rules? the domain isn't important if you'd like to redact it but i'm curious what is tripping this up (i have my suspicions but would like to confirm).

lkraav commented 2 years ago
{
    "result": [
        {
            "id": "5ddf5de2e53804a5a0389acb69dce58c",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "/institute/welcome/*"
                    }
                }
            ],
            "actions": [
                {
                    "id": "cache_level",
                    "value": "bypass"
                }
            ],
            "priority": 5,
            "status": "active",
            "created_on": "2021-09-15T01:33:59.000000Z",
            "modified_on": "2021-09-15T01:34:10.000000Z"
        },
        {
            "id": "a55f6bc7c9d120282d2ede44ed1c66d1",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "/institute/my-account/*"
                    }
                }
            ],
            "actions": [
                {
                    "id": "cache_level",
                    "value": "bypass"
                }
            ],
            "priority": 4,
            "status": "active",
            "created_on": "2021-05-12T14:12:23.000000Z",
            "modified_on": "2021-05-12T14:12:23.000000Z"
        },
        {
            "id": "f4057b6275c4379222a3c82c3b0884af",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "/institute/pricing/*"
                    }
                }
            ],
            "actions": [
                {
                    "id": "cache_level",
                    "value": "bypass"
                }
            ],
            "priority": 3,
            "status": "active",
            "created_on": "2021-01-27T16:03:52.000000Z",
            "modified_on": "2021-03-11T11:28:26.000000Z"
        },
        {
            "id": "572039bd116b7965051d953782b3d925",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "*/.well-known/*.txt"
                    }
                }
            ],
            "actions": [
                {
                    "id": "ssl",
                    "value": "off"
                }
            ],
            "priority": 2,
            "status": "active",
            "created_on": "2019-12-05T20:00:54.000000Z",
            "modified_on": "2019-12-05T20:00:54.000000Z"
        },
        {
            "id": "75fa798e127e4d387319ddb50bd4fb17",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "*/*"
                    }
                }
            ],
            "actions": [
                {
                    "id": "always_use_https"
                }
            ],
            "priority": 1,
            "status": "active",
            "created_on": "2019-12-05T19:57:33.000000Z",
            "modified_on": "2019-12-05T19:57:33.000000Z"
        }
    ],
    "success": true,
    "errors": [],
    "messages": []
}
jacobbednarz commented 2 years ago

the issue here looks to be always_use_https lacking a "value" key. i've pushed up a fix in #468; can you apply it to your installation and let me know if it addresses the issue for you?