Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#649 2016-11-02 20:12:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

Unfortunately, no amount of money would make me adopt this beast of a plugin. It’s like Black Ops in there!

But if it’s a simple case of syntax errors or warnings due to outdated PHP, then if someone could post any errors they see from debugging mode, so I have a clue where they occur in the plugin, then I can perhaps advise you how to patch it back to working health. Assuming I can find a recent copy of the plugin itself… is the one in the OP (0.14 patch 7, with gbp_admin_library v0.4.669) the most recent version?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#650 2016-11-02 21:16:43

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

Bloke wrote #302573:

is the one in the OP (0.14 patch 7, with gbp_admin_library v0.4.669) the most recent version?

As best I could determine. I made my own fork but I get completely lost trying to understand what the code is doing/

Offline

#651 2016-11-02 21:49:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

michaelkpate wrote #302574:

[OP is latest version] As best I could determine.

Thanks.

I get completely lost trying to understand what the code is doing/

You and me both! Unfortunately, people such as Graeme who are borderline genius are on a different plane of existence, which leave mere muggles such as myself playing catch-up.

I do, however, have a version of gbp_admin_library for MLP which has been modged and hacked to work — if not with Txp 4.6 in terms of visual style — at least a more modern OO programming style. If that’s any use to anyone running gbp_permanent_links, then by all means take the code. It may well squash a few errors.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#652 2016-11-03 08:57:06

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: gbp_permanent_links

1. Yes v0.14.7 is the latest one as much as I know (and v0.4.669 for the library).
Here are temporary download links:
gbp_permanent_links_0.14.7.txt
gbp_admin_library_0.4.669.txt

2. These are the errors I get in debugging mode –

In the diagnostics page I get this one:

Clean URL data test failed: <pre>A problem occurred while loading the plugin: <b>gbp_permanent_links</b> -> <b>Notice: unserialize(): Error at offset 5 of 1014 bytes on line 219</b></pre>

In the plugin page I get all these:

A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 1014 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()
A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 1015 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()
A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 904 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()
A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 1015 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()
A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 1015 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()
A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 1015 bytes on line 219

textpattern/lib/txplib_misc.php(615) : eval()'d code:219 unserialize()
GBPPlugin->gbp_serialized()
textpattern/lib/txplib_misc.php(615) : eval()'d code:134 call_user_func()
textpattern/lib/txplib_misc.php(615) : eval()'d code:57 GBPPlugin->load_preferences()
textpattern/lib/txplib_misc.php(812) : eval()'d code:1940 GBPPlugin->GBPPlugin()
textpattern/lib/txplib_misc.php:812 eval()
textpattern/index.php:159 load_plugins()

Offline

#653 2016-11-03 13:49:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

THE BLUE DRAGON wrote #302592:

Notice: unserialize(): Error at offset 5 of 1014 bytes on line 219

This is a general warning, one for each rule, and it’s to do with the way the data is stored in the prefs table. Basically, using serialize() to store binary data in a TEXT database field is a bad idea. There is a fix I can offer, but it will involve recreating your permanent links, since it’ll essentially wipe out everything you have so far.

So, if you want to embark on this patch, first visit your Admin->Permanent Links area and copy down or otherwise store/memorize the rules you’ve written. They will be trashed or lost once you do the following.

After you’re happy you’ve got a record of everything, you should delete your rules. If you can do it from the admin interface, fine. If not, in phpMyAdmin:

delete from txp_prefs where html = 'gbp_partial';
delete from txp_prefs where html = 'gbp_serialized';

Then go and edit the gbp_admin_library plugin. Find function gbp_serialized. In that function there are two case blocks for db_set and db_get. Replace both with this:

case 'db_set':
	return base64_encode(serialize($value));
break;
case 'db_get':
	return unserialize(base64_decode($value));
break;

[Code edited to fix problem highlighted by michaelkpate below]

All we’re doing is swapping serialize() and unserialize() out for json_encode() and json_decode() wrapping serialize() and unserialize() with base64 encoding/decoding to protect them during storage.

Then recreate your permanent link rules. All should be well.

Longer term I think I’ll see if it’s possible to patch gbp_admin_library with a more robust solution that’ll detect which system you have in place, so at least there’s some semblance of backwards compatibility for things like MLP. But for now, sorry, but I suspect your permanent link rules are trashed and I don’t know how to recover them.

I did look at this function which purports to show you where serialization errors have occurred, but I couldn’t get it to work: it just said the serialized version was fine (a fact corroborated by an online de-serializer, which had no trouble whatsoever with the permanent links stored in my prefs table). Go figure.

Last edited by Bloke (2016-11-03 22:53:27)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#654 2016-11-03 21:21:38

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

I have a test blog that I setup a few months ago that I had kind of forgotten about.

Some diagnostics:

Textpattern version: 4.6.2 
Site URL: presidents.cmsstyles.com
PHP version: 5.6.24
MySQL: 5.6.25-log

Anyway, I had never setup gbp_permanent_links on it. Today I installed it, made Stef’s changes, and then activated it.

I am not seeing any errors. I can go in and make a new rule, hit save, and everything again works fine.

But every time I get: You haven’t created any custom permanent links rules yet.

Offline

#655 2016-11-03 22:08:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

michaelkpate wrote #302633:

But every time I get: You haven’t created any custom permanent links rules yet.

My bad, sorry. I swear it was working earlier. Leave it with me.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#656 2016-11-03 22:51:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

Seems it isn’t able to reconstitute the partials properly if using json_decode() so we’ll have to fall back on base64. Those two case statements I said to mod above? Try replacing them with this block instead:

case 'db_set':
	return base64_encode(serialize($value));
break;
case 'db_get':
	return unserialize(base64_decode($value));
break;

I’ve edited my post above to correct the oversight, sorry for the hassle.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#657 2016-11-03 23:38:26

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

Bloke wrote #302635:

I’ve edited my post above to correct the oversight, sorry for the hassle.

Since we never have gotten this far without your help, we are not about to complain.

1) The Good – you can save a rule now. Yay!

2) The Not-So-Good – Going to the a page works but you end up in an endless loop of page refreshes.

I put in a rule just to experiment – section/year/title/ – You can see it here: http://presidents.cmsstyles.com/speeches/2016/declaration-of-war-with-japan/

I thought it might be because I turned debugging on but I turned it off and it has the same effect. I tried different rules and combos and nothing. I even refreshed the page templates directly from the current github repo.

Thoughts?

Offline

#658 2016-11-03 23:42:13

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

I see what it is now:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
			<head>
				<title>Great Presidential Speeches</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<meta http-equiv="refresh" content="0;url=http://presidents.cmsstyles.com/speeches/2016/declaration-of-war-with-japan/" />
			</head>
			<body>
			<a href="http://presidents.cmsstyles.com/speeches/2016/declaration-of-war-with-japan/">Moved Permanently</a>
			</body>
			</html>

This is getting inserted into the top of the page. Weird.

Offline

#659 2016-11-03 23:44:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

michaelkpate wrote #302636:

1) The Good – you can save a rule now. Yay!

At least, sort of… I just tried some more rules and they weren’t saving properly. Things like /section/ return /NaN/ after saving :-(

2) The Not-So-Good – Going to the a page works but you end up in an endless loop of page refreshes.

Nasty. I don’t get that, but then my rules don’t save properly so maybe that has something to do with it. *sigh* back to the drawing board…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#660 2016-11-03 23:49:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: gbp_permanent_links

All this splitting up of rules to store in prefs is complicating matters and is a holdover from ancient Txp versions when pref values were limited to 255 characters. Now we can store huge values it’s no longer necessary, so this entire part of the plugin/admin library could be rewritten. If I understood it…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB