joshp23 / YOURLS-Expiry

YOURLS plugin to define conditions under which links will expire - time and click limited links
GNU General Public License v3.0
35 stars 13 forks source link

Unable to delete expiry #35

Closed NewRedsquare closed 3 years ago

NewRedsquare commented 3 years ago

Technical details regarding my environment

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

Omniru commented 3 years ago

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), ";

NewRedsquare commented 3 years ago

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