[3.3][RC] Event if a post / topic changes?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
kilobyte3
Registered User
Posts: 29
Joined: Sun Apr 24, 2016 7:07 pm

[3.3][RC] Event if a post / topic changes?

Post by kilobyte3 »

On my site, I have a standalone Phpbb forum and I got a list about the latest posts/topices. So far it's very good, but this requires two SQL queries, and I need to eliminate them, out of performance purpose. I want to cache those 2 list, but of course if a new topic created/deleted/posts updates, this cache should be erased. So far I haven't found a good Phpbb event. Or I couldn't even figure out how to subscribe on these events. Any idea?
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: [3.3][RC] Event if a post / topic changes?

Post by 3Di »

Where is located your extension's code to see?

You can cache the queries (TTL) in two ways, directly or using cache files.
Have a look at my TPOTM extensions to see how this is done.

https://github.com/3D-I/tpotm
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
kilobyte3
Registered User
Posts: 29
Joined: Sun Apr 24, 2016 7:07 pm

Re: [3.3][RC] Event if a post / topic changes?

Post by kilobyte3 »

thanks for the answer, now I'm more clever about this. I didn't even know I need an extension... so I have this:

\ext\acme\config\services.yml

Code: Select all

services:
    acme.demo.listener:
        class: acme\demo\event\main_listener
        tags:
            - { name: event.listener }
\ext\acme\demo\composer.json

Code: Select all

{
    "name": "acme/demo",
    "type": "phpbb-extension",
    "description": "Custom extension",
    "homepage": "https://github.com/phpbb/phpbb-ext-acme-demo",
    "version": "0.1.0",
    "time": "2013-11-05",
    "keywords": ["phpbb", "extension", "acme", "demo"],
    "license": "GPL-2.0-only",
    "authors": [
        {
            "name": "Kilobyte",
            "email": "nickvergessen@localhost",
            "homepage": "https://github.com/nickvergessen/",
            "role": "Lead Developer"
        }
    ],
    "require": {
        "php": ">=5.4.0",
        "composer/installers": "~1.0"
    },
    "require-dev": {
        "phpbb/epv": "dev-master"
    },
    "extra": {
        "display-name": "Acme Demo Extension",
        "soft-require": {
            "phpbb/phpbb": "~3.2"
        }
    }
}
\ext\acme\demo\event\main_listener.php

Code: Select all

<?php
namespace acme\demo\event;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
echo '1';die;
class main_listener implements EventSubscriberInterface
{
    /**
     * Assign functions defined in this class to event listeners in the core
     *
     * @return array
     */
    static public function getSubscribedEvents()
    {
        echo '2';die;
        return [
            'core.user_setup' => 'load_language_on_setup',
        ];
    }

    /**
     * Load the Acme Demo language file
     *     acme/demo/language/en/demo.php
     *
     * @param \phpbb\event\data $event The event object
     */
    public function load_language_on_setup($event)
    {
        $lang_set_ext = $event['lang_set_ext'];
        $lang_set_ext[] = [
            'ext_name' => 'acme/demo',
            'lang_set' => 'demo',
        ];
        $event['lang_set_ext'] = $lang_set_ext;
    }
}
notice the two die() commands, but they never run. This means, my extension doesn't get run. I enabled id, deleted all cache, no joy.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: [3.3][RC] Event if a post / topic changes?

Post by 3Di »

I didn't say you needed an extension and what you posted doesn't tell me anything to be honest (about the ACME code). I didn't understand if you have an extension (apparently not) or if you have a script, in the latter case maybe this is the wrong forum.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
kilobyte3
Registered User
Posts: 29
Joined: Sun Apr 24, 2016 7:07 pm

Re: [3.3][RC] Event if a post / topic changes?

Post by kilobyte3 »

I was reading this: https://area51.phpbb.com/docs/dev/3.3.x ... vents.html thats why I started out with an extension.
kilobyte3
Registered User
Posts: 29
Joined: Sun Apr 24, 2016 7:07 pm

Re: [3.3][RC] Event if a post / topic changes?

Post by kilobyte3 »

ok, I got it working, the config.yml was at wrong place
Post Reply

Return to “Extension Writers Discussion”