Skip to content

Conversation

@Soare-Robert-Daniel
Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel commented Jan 22, 2024

Close https://github.com/Codeinwp/tweet-old-post-pro/issues/480

Summary

Added better service response handling and upgraded the URL to use the latest API endpoint.

Description

The posting mechanism added a message like that ends Error, database insert failed. This was caused by the function get_url, which tries to shorten the URL by using is.gd service.

To replicate this issue you need a valid domain. The services work only with URLs that are available on the internet and are not on the blocklist (FYI: tastewp URLs are on the blacklist).

The main problem is that when services cannot process the URL, it will give something like this as a response:

HTTP/1.1 200 OK
CF-Cache-Status: DYNAMIC
CF-RAY: 8498b6a71ad9c29b-VIE
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Mon, 22 Jan 2024 15:08:39 GMT
Server: cloudflare
Set-Cookie: __cf_bm=mW5ZRykpgHu1OaXthztTO_deplxvZmh1GJQQh5ZjYe4-1705936119-1-Ac1gBGUi4m8U+2XoNRIPkBDKqlflPfMpNyDzVnOqUUboQiG9+WsZOp8/Iv56lF01CuOq1UdT0QkG9pzUkVA7fvQ=; path=/; expires=Mon, 22-Jan-24 15:38:39 GMT; domain=.is.gd; HttpOnly; Secure; SameSite=None
Transfer-Encoding: chunked

Error, database insert failed

Because the response error is 200, the code accepted the string without further verification.

To solve this, I added a check to see that the response is a URL.

Any other response from the server will be treated as an error and logged:

image

There was also a report about the same issue for people who did not use the URL shortener https://github.com/Codeinwp/tweet-old-post-pro/issues/480#issuecomment-1896311145

I tested all the codes and could not reproduce them.

Testing

  • Check if the logger is working when is.gd is not giving the URL. You can test with TasteWP or a local instance.
  • Check if the URL is shortened. For is.gd, you will need a non-banned and online available instance.

@Soare-Robert-Daniel Soare-Robert-Daniel self-assigned this Jan 22, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel marked this pull request as ready for review January 22, 2024 16:09
@github-actions
Copy link

Plugin build for aba4076 is ready 🛎️!

@irinelenache
Copy link

@Soare-Robert-Daniel Tested and the issue is fixed now 🚀

@Soare-Robert-Daniel Soare-Robert-Daniel merged commit 2793338 into development Feb 1, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel deleted the fix/is-gd-response branch February 1, 2024 07:46
@pirate-bot
Copy link
Contributor

🎉 This PR is included in version 9.0.23 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants