Toggling trackbackgeneration

Discussion corner for Developers of Serendipity.
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Toggling trackbackgeneration

Post by onli »

I'm trying to toogle the trackbackgeneration of an entry which was published into the future, but is now released. Thought that

Code: Select all

$stored_entry = serendipity_fetchEntry('id', $entry['id'], 1, 1);
$_SESSION['serendipityRightPublish'] = true;
serendipity_updertEntry($stored_entry);
should get the job done, but it shows no effect. I also tried to follow the admin/entries.inc.php and to call serendipity_handle_references()...

How can the trackbackgeneration be toggled automatically without saving the entry again manually in the editor?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!

Yes, that does not work.

Trackbacks are only re-triggered if you set an entry to "draft" and then to "publish" again.

Or you delete the entries in the serendipity_references database and store again.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Toggling trackbackgeneration

Post by Don Chambers »

Does this mean that trackbacks are not generated for future entries?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!
Don Chambers wrote:Does this mean that trackbacks are not generated for future entries?
Yes, it has been this way from day 1 in serendipity.

Regards
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Toggling trackbackgeneration

Post by Don Chambers »

Learn something new every day I guess! :wink:
=Don=
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Toggling trackbackgeneration

Post by onli »

I want to change that. And it seems to work.
When an entry is saved into the future, no references are created yet (so saving again as draft and publishing is not necessary :) ). updertEntry was the way to go, just needed to remove loginname and email from the fetched entry.

The last thing needed, which would need modification to the core as far as I can see, would be a way to silence the trackbackgeneration (error and success-messaged are printed to the bottom of the page at the moment). A parameter to updertEntry?

PS: The mechanism is to remember the entry and start the generation after its release as soon as a page gets created.
Attachments
serendipity_event_delayed_trackbacks.tar.gz
(1.77 KiB) Downloaded 389 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!

I'd use ob_Start() before calling updertEntry, so you can even store this debug output somewhere, and then discard it.

I saw that you set the rightpublish session var. You should keep track of the original content, and reset it after the update. Else, anyone with a sesssion would be able to publish entries after that. ;)

Also, in the setpuDB routine I would remove the backticks ` so that the code is compatible for SQLite and PostgreSQL. In the end, merging the code into the trackbacks-event plugin would also be a great addition? In that case, its update routine would need some kind of hidden configuration value, and if that does not exist, the plugin would need to create the missing database table.

generateDelayed() should IMHO only inclkude the trackback library, if at least one tracbkack is to be sent, to save some space. otherwise the lib would be included on every page request. Plus, you might want to add a simple random(1, 10) function and only execute the check when that number is 1 - so the overhead of this SQL query would only occur about once every 10 page requests, which should still be sufficient and much less on the performance impact side.

The basic idea of this is very nice, and should work perfectly! MAny thanks for working on this!

REgards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Toggling trackbackgeneration

Post by onli »

Thanks for your advices :)

Think I implemented everything, but i'm not totally sure that the place for the database-check is the best choice.
Attachments
serendipity_event_trackback-1.12.tar.gz
(5.88 KiB) Downloaded 393 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!

Yes, I would place the db_upgradecheck (as well as the $delayed_trackbacks check) inside the generateDelayed() method, as well as inside the backend_save/backend_publish hooks. This way it doesn't get executed everytime...?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Toggling trackbackgeneration

Post by onli »

Alright, I stored the upgrade-check in a function and called it in delay() and generateDelayed() :)
The $delayed_trackbacks moved into the ifs.
Attachments
serendipity_event_trackback.tar.gz
(5.9 KiB) Downloaded 387 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!

That's great! Anyone here wants to testdrive the plugin? Don?

I'd like to have it in spartacus of course after a bit of testing :-))

Thanks for your efforts!

Regards,
garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Toggling trackbackgeneration

Post by Don Chambers »

garvinhicking wrote:Anyone here wants to testdrive the plugin? Don?
It will be difficult for me to put this into a live environment that has the combination of future entries AND trackbacks. I can, however, try it in one of my test sites.

Before I do, why is this an event plugin and not a core feature?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Toggling trackbackgeneration

Post by garvinhicking »

Hi!

It needs to execute on a conditional basis, so it actually requires an event hook to execute. Adding a core feature in there would mean a lot of overhead...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Toggling trackbackgeneration

Post by Don Chambers »

OK - I will give it a try when I take a break from my own s9y headaches with aMember! :wink:
=Don=
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Toggling trackbackgeneration

Post by onli »

>OK - I will give it a try when I take a break from my own s9y headaches with aMember!
That'd be great :D

>Adding a core feature in there would mean a lot of overhead...
Are you sure about that? We could add the delay() to updertEntry and the check to genpage. Sure, it would mean more code in the core, but (performance-)overhead? Or do you mean the additional database-query of the functionality itself?

PS: Maybe there is even further use for such a cron-like system?
Post Reply