joshp23/YOURLS-Expiry

Unable to delete expiry

NewRedsquare opened this issue · 2 comments

Technical details regarding my environment

  • YOURLS version: 1.8.1

  • Plugins enabled:

    1. yourls-password-protection/plugin.php
    2. Always-302/plugin.php
    3. usrv/plugin.php
    4. iqrcodes/plugin.php
    5. yourls-keyword_charset_length-master/plugin.php
    6. timezones-master/plugin.php
    7. yourls-login-timeout-master/plugin.php
    8. yourls-pseudonymize-master/plugin.php
    9. rscrub/plugin.php
    10. yourls-api-delete/plugin.php
    11. bulk_api_bulkshortener-master/plugin.php
    12. yourls-bulk-import-and-shorten-master/plugin.php
    13. dont-log-bots-master/plugin.php
    14. admin_issue_diagnostic-master/plugin.php
    15. sleeky-backend/plugin.php
    16. expiry/plugin.php
    17. authMgrPlus/plugin.php
    18. yourls-advanced-reserved-urls-master/plugin.php
  • YOURLS DB Ver: 506

  • PHP version: 7.4.18

  • Server OS Build: Linux

  • Server & version: nginx/1.14.2

  • Browser information: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0

  • Generated by the AID Plugin ver 1.0

Bug description

What is the current behavior?

The plugin is completely unusable from my side. I can add (and add automatically) expiry to new links, but when i want to manually delete a link, all i get is a link like this https://yourls.domain/admin/plugins.php?page=expiry&action=remove&key=fediverse%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD

It sends me back to the Expiry menu without deleting the entry (i double-checked with mysql table)

**The issue appears again EVEN with a fresh YOURLS and empty database withou any plugin **

I tried both git clone and downloading last release zip file

In the latest version 2.4.0 I had issues with the create statement creating the field as a binary type instead of a varchar(200) like is shown in the expiry.sql code. After changing that type to varchar yourl's aura/sql implementation of fetchOne is able to find the record in the database and successfully delete them as expected.

`yourls_add_action( 'activated_expiry/plugin.php', function () {

global $ydb;
// Create the expiry table
$table = YOURLS_DB_PREFIX . 'expiry';
$table_expiry  = "CREATE TABLE IF NOT EXISTS `".$table."` (";
$table_expiry .= "keyword varchar(200) NOT NULL, ";
$table_expiry .= "type varchar(5) NOT NULL, ";
$table_expiry .= "click varchar(5), ";
$table_expiry .= "timestamp varchar(20), ";
$table_expiry .= "shelflife varchar(20), ";
$table_expiry .= "postexpire varchar(200), ";
$table_expiry .= "PRIMARY KEY (keyword) ";
$table_expiry .= ") ENGINE=InnoDB DEFAULT CHARSET=latin1;";

$tables = $ydb->fetchAffected($table_expiry);

});`

I also added an expiration_timestamp and updated the code to use it to optimize querying in large database collections (though still testing this):
$table_expiry .= "expiration_timestamp bigint(20), ";

Thank you a LOT, this fix should be pushed to this repo.