Upgrading YOURLS and Database Upgrade Errors Fix



yours 1 4 upgrade 4 Upgrading YOURLS and Database Upgrade Errors Fix

Today YOURLS 1.4 was released, but the database upgrade script created some errors for some people, dead links, and the stats are not working. We can fix all that. Be sure to logout of the old version you will be upgrading from before starting the upgrade, or you might see the Install YOURLS page and link, rather than the Upgrade YOURLS page and link. First lets go over the changes in the config.php file.

Configuration

There have been some changes to the config.php file, which you will create from the includes/config-sample.php file. If you are upgrading you have a few unexpected steps to upgrade our config.php file. Open up the new config-sample.php to create a new config.php file, then copy the data entries for each existing field into the new config.php file. You will need to copy and paste the lines for YOURLS_DB_TABLE_URL and YOURLS_DB_TABLE_NEXTDEC into the new config.php file, then after upgrading the database you’ll need to remove the YOURLS_DB_TABLE_NEXTDEC entry from the config.php file.

Upgrade

Go to yoursite dot com/admin/upgrade.php, and if everything in your config.php file is correct your should see the following.

yours 1 4 upgrade 1 Upgrading YOURLS and Database Upgrade Errors Fix

This is where the upgrade script creates new tables, but it failed to create a new .htaccess file for me, so I had to create it myself.

yours 1 4 upgrade 2 Upgrading YOURLS and Database Upgrade Errors Fix

Once the upgrade process is completed you should see the following page.

yours 1 4 upgrade 3 Upgrading YOURLS and Database Upgrade Errors Fix

Fixing Database Errors and Statistics Errors with .htaccess

During the upgrade you might run into an error that says something like:

Huho... Could not update rown with url='http://www.nerdgrind.com/ajay-bhatt-co-creator-of-usb-port-on-conan/', from keyword '77' to keyword '25'

The entry is in the database, but during the upgrade process the example entry above was changed from a url ending in 25 to a new short url ending in 77. To fix this problem you’ll need to add an entry to your .htaccess file. For the example above we would add:

Redirect permanent /25 http://ngurl.me/77

Notice how the old short url ending "25" comes before the new short url ending "77". We are redirecting from the old url to the new url. These redirect lines will need to come before the lines that run YOURLS. A properly listed code would look like the following:

#Redirecting database 1.3 to 1.4 upgrade errors

Redirect permanent /26 http://ngurl.me/78
Redirect permanent /24 http://ngurl.me/76
Redirect permanent /25 http://ngurl.me/77

#End database redirect url correction

# BEGIN ShortURL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z]+)/?$ yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)+/?$ yourls-infos.php?id=$1 [L]
# END ShortURL

yours 1 4 upgrade 5 Upgrading YOURLS and Database Upgrade Errors Fix

For those people, like myself, who the script failed to create a new .htaccess file, we were pointed to a the .htaccess example page for help. That’s where I noticed the reason my new stat links were resulting in a 404 error page. A new line pointing to the stats script (yourls-infos.php) needs to be added to the .htaccess file. The new line should be:

RewriteRule ^([0-9A-Za-z]+)+/?$ yourls-infos.php?id=$1 [L]

You can see in the example above exactly where the new line should be listed in the .htaccess file.

This new line to make the statistics work was not mentioned on the Install/Upgrade YOURLS page, but now you know.

Click here to learn how to backup your YOURLS database.



Short Link - http://ngurl.me/2j Posted on October 14, 2009 at 2:55 pm (PST)
Tags: | | | | | | | | | | | | | | | | | | | | |


One comment on “Upgrading YOURLS and Database Upgrade Errors Fix

  1. I’m having a canonical redirect issue. Calls to www.gum.bo get diverted to /admin, while calls to gum.bo go to the home page.

    .htaccess file matches example!

    Any thoughts?

    # BEGIN YOURLS

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 [L]
    RewriteRule ^([0-9A-Za-z]+)+/?$ /yourls-infos.php?id=$1 [L]
    RewriteRule ^([0-9A-Za-z]+)+all/?$ /yourls-infos.php?id=$1&all=1 [L]

    # END YOURLS

Leave a Reply

Your email address will not be published. Required fields are marked *

*

6,786 Spam Comments Blocked so far by Spam Free Wordpress

HTML tags are not allowed.

© Copyright Nerd Grind 2009 - 2010. All rights reserved.