[DigitalPoint] App for Cloudflare®

[DigitalPoint] App for Cloudflare® 1.8.2

No permission to download
Okay, so I'm guessing most of your class B operations are coming from users viewing full size image attachments. Those aren't cached because they go through the application (XenForo) to do permission check for each request.
You're probably right there. When I'm only at 20% of max free operations, lowering that number isn't too much of a concern.
 
Hi, we are currently testing this addon and we noted that we're getting some intermittent gateway timeout errors when attempting to load certain things such as the addon options and the R2 options in the ACP. Has anyone else experienced the same?

We also get this error when we attempt to access the Access or DMARC management links in the Cloudflare setup options:

Code:
ErrorException: [E_WARNING] Undefined variable $hostnameTry in src/addons/DigitalPoint/Cloudflare/Repository/Cloudflare.php at line 834

    XF::handlePhpError() in src/addons/DigitalPoint/Cloudflare/Repository/Cloudflare.php at line 834
    DigitalPoint\Cloudflare\Repository\CloudflareAbstract->getZoneId() in src/addons/DigitalPoint/Cloudflare/Repository/Cloudflare.php at line 851
    DigitalPoint\Cloudflare\Repository\CloudflareAbstract->getAccountId() in src/addons/DigitalPoint/Cloudflare/Repository/Cloudflare.php at line 1444
    DigitalPoint\Cloudflare\Repository\CloudflareAbstract->getAccessApps() in src/addons/DigitalPoint/Cloudflare/Admin/Controller/Cloudflare.php at line 729
    DigitalPoint\Cloudflare\Admin\Controller\Cloudflare->actionAccess() in src/XF/Mvc/Dispatcher.php at line 352
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2483
    XF\App->run() in src/XF.php at line 524
    XF::runApp() in admin.php at line 13

Looking at the PHP code it appears this variable is supposed to be populated within the getZoneID function. I'm not the best at reading PHP code but it looks like it's doing something with the hostname variable, which is set to null by default. It looks like this value is supposed to be populated from a getSiteUrl() function that pulls the board URL directly from Xenforo using XF::options()->boardUrl, but I can't really tell where it goes from there to cause an error. As far as I can tell the ACP board URL is set accurately and there is a DNS entry for the subdomain we're hosting the test site on in the cloudflare dashboard.
 
Last edited:
Can you post a screenshot of the board URL setting as you have it set? One thing I can think of off the top of my head would be if the URL is not a valid URL somehow (like if you had something in that setting, but it's technically not a URL).

More specifically, the hostname is extracted from the URL with PHP's parse_url() function.
On seriously malformed URLs, parse_url() may return false.
 
I will send you a message with the board URL setting, but I do not want to share the test site publicly even though it is closed for viewing. The setting matches the "suggested URL" that XF recommends.
 
I will send you a message with the board URL setting, but I do not want to share the test site publicly even though it is closed for viewing. The setting matches the "suggested URL" that XF recommends.
Maybe try deleting the board URL setting, save it and manually retype it in? The URL looks okay, but maybe there is some stray invalid/invisible characters in there? I set up a test scenario on my end and it was able to handle that URL just fine (however, I typed it in, not copy/pasted what you have) since it was a screenshot.

Just got the normal/expected error (since that zone isn't on my Cloudflare account) of:
Cloudflare zone not found: subdomain.yourdomain.com
 
Maybe try deleting the board URL setting, save it and manually retype it in? The URL looks okay, but maybe there is some stray invalid/invisible characters in there? I set up a test scenario on my end and it was able to handle that URL just fine (however, I typed it in, not copy/pasted what you have) since it was a screenshot.

Just got the normal/expected error (since that zone isn't on my Cloudflare account) of:
Same issue even when retyping it out. Also getting the same error on a template too when loading the board basic options:

1683133155370.png


EDIT: I tried a php script to run a var_dump on what parse_url returns from the PHP_HOST_URL and it returned the subdoman.domain.com as a string, as expected. Plugged the result into the PHP code directly for the $hostname variable definition on line 785 and it works when hardcoded. So definitely something going on.
 
Last edited:
Same issue even when retyping it out. Also getting the same error on a template too when loading the board basic options:

View attachment 285522


EDIT: I tried a php script to run a var_dump on what parse_url returns from the PHP_HOST_URL and it returned the subdoman.domain.com as a string, as expected. Plugged the result into the PHP code directly for the $hostname variable definition on line 785 and it works when hardcoded. So definitely something going on.
Ya, hard to say exactly what's going on without being able to replicate it. What version of PHP are you using? Maybe can try replicating it with whatever version you are using. Although to be honest, I feel like if there was some issue with a certain version of PHP, someone would have run across it by now. But worth checking out...
 
Ya, hard to say exactly what's going on without being able to replicate it. What version of PHP are you using? Maybe can try replicating it with whatever version you are using. Although to be honest, I feel like if there was some issue with a certain version of PHP, someone would have run across it by now. But worth checking out...
The current version of PHP used on the forum is 8.1.13, specifically using php8.1-fpm and not standard php. I just tried rolling it back to 8.0.28 and 7.4.33 with the same result. I don't think it's with the PHP version.
 
@digitalpoint the addon only gets a list of the first 20 buckets even when there are more in my CF account. Can you increase the limit or get the number of buckets to display in the dropdown?
 
Ya, I explicitly set the number of buckets per page to the max now (for next version) which is 1,000 (looks like the API defaults to 20).

Just out of curiosity, why do you have so many buckets?
 
Anyone else get this on their XF admin dash today? Just came up out of nowhere. I'm thinking some global cache / cdn has some downtime causing a js script to fail.

Uncaught (in promise) Error: Container is not defined
at gvjs_Qh (jsapi_compiled_default_module.js:144:188)
at gvjs_E_.gvjs_Qn [as constructor] (jsapi_compiled_default_module.js:457:356)
at new gvjs_E_ (jsapi_compiled_geochart_module.js:78:526)
at drawRegionsMap (admin.php:4705:15)

  • GuzzleHttp\Exception\ConnectException: Template admin:index error: cURL error 6: Could not resolve host: api.cloudflare.com; Unknown error (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
  • src/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200
  • Generated by: Nik
  • May 8, 2023 at 4:50 PM
Looks like something is down. Could be isolated to my DC I guess.

@digitalpoint anyway we can not kill the dash if cloudflare is down?
 
Anyone else get this on their XF admin dash today? Just came up out of nowhere. I'm thinking some global cache / cdn has some downtime causing a js script to fail.

Uncaught (in promise) Error: Container is not defined
at gvjs_Qh (jsapi_compiled_default_module.js:144:188)
at gvjs_E_.gvjs_Qn [as constructor] (jsapi_compiled_default_module.js:457:356)
at new gvjs_E_ (jsapi_compiled_geochart_module.js:78:526)
at drawRegionsMap (admin.php:4705:15)

  • GuzzleHttp\Exception\ConnectException: Template admin:index error: cURL error 6: Could not resolve host: api.cloudflare.com; Unknown error (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
  • src/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200
  • Generated by: Nik
  • May 8, 2023 at 4:50 PM
Looks like something is down.
Well... a couple things here... looks like two different things happening to me.

drawRegionsMap is used by the Better Google Analytics addon, not the Cloudflare addon. However, the other error you are seeing with the inability to resolve the IP for api.cloudflare.com, IS for this addon. And that error looks like simple network connectivity issue for your server. Both errors look like they are probably network connectivity issues with your server.

Did the errors sort themselves out and go away by chance (as in network issues were fixed on your server)? It's more probable that your server had a network issue than it is that Cloudflare's 300 data centers went down concurrently (only one would need to be up in order for api.cloudflare.com to resolve).
 
Well... a couple things here... looks like two different things happening to me.

drawRegionsMap is used by the Better Google Analytics addon, not the Cloudflare addon. However, the other error you are seeing with the inability to resolve the IP for api.cloudflare.com, IS for this addon. And that error looks like simple network connectivity issue for your server. Both errors look like they are probably network connectivity issues with your server.

Did the errors sort themselves out and go away by chance (as in network issues were fixed on your server)?

They did just now, I'm aware they were network issues. I'm wondering if there's anyway we can avoid killing the XF dashboard if the JS fails to load for your addon and/or CF happens to be unavailable.
 
Well the Cloudflare stats on the admin home page is done via an AJAX call to get the underlying data. While I haven't tested it to the point where I intentionally break servers to see what happens, I'd think that the only thing that should happen is the AJAX request fails and you don't get any stats in that block. Do you happen to have a screenshot of what you were seeing that's not that?
 
Well the Cloudflare stats on the admin home page is done via an AJAX call to get the underlying data. While I haven't tested it to the point where I intentionally break servers to see what happens, I'd think that the only thing that should happen is the AJAX request fails and you don't get any stats in that block. Do you happen to have a screenshot of what you were seeing that's not that?

Yeah it was a blank screen hence my concern 😉

Try it out and see if you can recreate it, just fake a failure by changing endpoint or a static DNS entry to a non existent endpoint.
 
Well, I don't think it would be from the Cloudflare addon. Like I said, I went out of my way to make sure any issue with analytics or API (or in your case network connectivity) shouldn't break the admin area. The only thing coming from the server-side related to Cloudflare analytics is an empty placeholder box where stats will go. Then when the page is loaded, it triggers an AJAX call to actually populate the charts. You can kind of see what I mean if you watch closely... there are no charts to be shown initially when the page loads, and if you watch the underlying HTTP requests from your browser, you'll see an AJAX call get made to get data for the charts. So as far as I can think of, Cloudflare API issues shouldn't break anything beyond you won't get the actual charts shown (but the rest of the page should show up). It's the AJAX call that makes the API call, which would be after the admin page renders.
 
I'm getting the following error:
Code:
Error: Call to a member function getBody() on array src/addons/DigitalPoint/Cloudflare/Traits/XF.php:146

#0 src/addons/DigitalPoint/Cloudflare/Api/Cloudflare.php(503): DigitalPoint\Cloudflare\Api\Cloudflare->parseResponse(Array)
#1 src/addons/DigitalPoint/Cloudflare/Api/Advanced.php(812): DigitalPoint\Cloudflare\Api\CloudflareAbstract->makeRequest('HEAD', 'attachments/120...', Array, true, 'internaldata-to...')
#2 src/addons/DigitalPoint/Cloudflare/League/Flysystem/Adapter/R2.php(195): DigitalPoint\Cloudflare\Api\Advanced->headR2Object('internaldata-to...', 'attachments/120...')
#3 src/addons/DigitalPoint/Cloudflare/League/Flysystem/Adapter/R2.php(83): DigitalPoint\Cloudflare\League\Flysystem\Adapter\R2->getMetadata('attachments/120...')
#4 src/vendor/league/flysystem/src/Filesystem.php(57): DigitalPoint\Cloudflare\League\Flysystem\Adapter\R2->has('attachments/120...')
#5 [internal function]: League\Flysystem\Filesystem->has('attachments/120...', Array)
#6 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(431): call_user_func_array('League\\Flysyste...', Array)
#7 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(395): League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod('has', Array)
#8 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(128): League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall('has', Array)
#9 src/vendor/league/flysystem/src/MountManager.php(313): League\Flysystem\EventableFilesystem\EventableFilesystem->has('attachments/120...')
#10 src/XF/Entity/AttachmentData.php(228): League\Flysystem\MountManager->has('attachments/120...')
#11 src/XF/ControllerPlugin/Attachment.php(9): XF\Entity\AttachmentData->isDataAvailable()
#12 src/XF/Pub/Controller/Attachment.php(45): XF\ControllerPlugin\Attachment->displayAttachment(Object(XF\Entity\Attachment))
#13 src/XF/Mvc/Dispatcher.php(352): XF\Pub\Controller\Attachment->actionIndex(Object(XF\Mvc\ParameterBag))
#14 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Index', Object(XF\Mvc\RouteMatch), Object(Snog\Forms\XF\Pub\Controller\Attachment), NULL)
#15 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Snog\Forms\XF\Pub\Controller\Attachment), NULL)
#16 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#17 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#18 src/XF.php(524): XF\App->run()
#19 index.php(20): XF::runApp('XF\\Pub\\App')
#20 {main}

array(4) {
  ["url"] => string(75) "/comunidad/attachments/whatsapp-image-2021-09-14-at-12-39-24-1-jpeg.208571/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

At the same time, these two have come up as well because of the same attachment:
Code:
ErrorException: Cloudflare: String could not be parsed as XML / null src/XF/Error.php:77
Code:
ErrorException: Cloudflare: Invalid response, code: 499 / src/XF/Error.php:77

Could it be because of the filename containing many numbers and characters?
 
For FAQ update:

Prior to enabling R2 in admin panel, these are the commands that should be run, to avoid broken attachments:
Code:
rclone sync data r2:<DATA_BUCKET>/ --verbose --transfers 10
rclone sync internal_data/attachments r2:<INTERNAL_DATA_ATTACHMENTS_BUCKET>/attachments --verbose --transfers 10
 
Last edited:
  • Like
Reactions: rdn
Top Bottom