Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
674 views
in Plugins by
I'm building a plugin. So far, a number of changes made locally have been synced with the version online. And they worked satisfactorily

At some point, however, it turns out the plugin class online is absolutely dead. I var_dump /output random things, they have no effect. I even remove the overridden methods and they continue working. These methods make modifications to the PHP. So, it's impossible for this to be a caching problem

Checked the error log and no new message is written

If I disable the plugin, all the updates truly vanish. Re-enable it and it continues from the last state where my changes had any effect. I was originally weirded out by the disparity in behaviour, thinking some other plugin /theme was overwriting my changes. Funny enough, outputting anything from there or even clearing entire plugin file has no effect

How else can I debug this, please?
Q2A version: 1.8.6
by
> So, it's impossible for this to be a caching problem

Not really true. I actually use OPcache for PHP: https://www.php.net/manual/en/book.opcache.php

Also, you could be using some caching service such as CloudFlare, among others.

Check if the OPCache extension is enabled in your server.
by
Nvm Pupi. I've isolated this to what the problem is: The SnowFlat theme outputs certain content that I was trying to override from my plugin layer. Turns out that this causes it to skip my layer and just call the base theme object. So, those methods are only overridable by extending the theme. I created an issue on github, with code examples of what I've done https://github.com/q2a/question2answer/issues/971

I can equally make project available if that's necessary. Thank you
by
> this causes it to skip my layer and just call the base theme object

It works the other way around. You can see this in the example code here: https://docs.question2answer.org/plugins/layers

Feel free to edit the question here with more complete code examples.
by
You don't understand. Code in my layer class doesn't execute if that method exists on SnowFlat theme class.  I don't really know how to use code formatting here. I modified the include statement on my theme to look like this

```php
require_once __DIR__ . '/../SnowFlat/qa-theme.php';

    use qa_html_theme as SnowFlat;

    class qa_html_themeX extends SnowFlat {
```

And it now includes correctly, but sadly doesn't work cuz of clashing class names. The aliasing doesn't work and if I change my class's name, Q2A no longer recognizes it as a theme entry. I guess I'll just wing it without a fancy solution like I'm trying to. I'll just dump the thousands of lines from SnowFlat into my own theme entry class and override the methods there, directly
by
+1
Ah, OK. How do I mark your comment as answer?

My layer will now extend the theme cloned from SnowFlat instead of the base theme layer

1 Answer

0 votes
by
The first step for advanced themes section in the docs states:

> 1. Choose one of Question2Answer's standard themes as a starting point. Make a copy of its directory in Q2A's qa-theme directory, and give the copy your chosen theme name

Themes extend the base theme. Layers extend themes. Themes do not extend themes.
...