[OJS] generic plugin callback not running

I am in a similar state as this:
https://pkp.sfu.ca/support/forum/viewtopic.php?f=9&t=13034
Except running OJS 2.4.6.0
I used the same method as the OP to verify the hook is registered, and I have enabled the plugin.

The upgrade script (php tools/upgrade.php upgrade) created an entry for my plugin, in the versions table but any call to the hook still returns a blank page.

The plugin code is as follows:

class ZohoMailerPlugin extends GenericPlugin {

function register($category, $path) {
    if (parent::register($category, $path)) {
        if ($this->getEnabled()) {
            HookRegistry::register('Mail::send', array(&$this, 'callback') );
            $hooks = HookRegistry::getHooks();
            var_dump($hooks);
        }
        return true;
    }
    return false;
}
function callback($hookName, $args) {
    // just to see if this gets called
    echo "caught";
 }


}

What else am I missing?

Hi,

Do you have any entry in your php error log that might be related with this?

Cheers,
Bruno

Hi @ChanOmegaWebDesign,

I suspect your plugin isn’t properly registered with the system. Is there a mismatch between the plugin’s information and the stuff in the version.xml descriptor? (This would be reflected in the versions table after running the update script.)

Regards,
Alec Smecher
Public Knowledge Project Team

Only related to this line:

var_dump($hooks);

Because it tries to set headers after the output, after commenting it out, no errors have been logged.

What kind of mismatch am I looking for?
-thanks

Hi @ChanOmegaWebDesign,

The contents of the <application> element should match the last part of the pathname that the plugin is in, and the <class> element should match the name of the plugin class. If you have to correct one of these, also correct it in the versions table.

Regards,
Alec Smecher
Public Knowledge Project Team

This was mismatched, I corrected it and the versions table, but I still get a blank page. I ran the upgrade script again, still blank page, still a really long load time.

Here is my version.xml and path info:

Hi @ChanOmegaWebDesign,

What does the relevant entry in the versions table look like?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @ChanOmegaWebDesign,

That looks OK to me – can you re-check a few of your previous avenues, like making sure the plugin is enabled, checking the error log, etc.? I’m also a little concerned about the blank page – can you try linting the PHP files in your plugin (php -l /path/to/php-file)?

Also, just in case, flush the .php files in the cache/ subdirectory.

Regards,
Alec Smecher
Public Knowledge Project Team

No errors were found in the php files, however when I changed the config to turn off smtp, I no longer get a blank page but it still skips right over my callback.

So then I cleared out the cache, emptied my php error log, dropped all the tables, set config installed=Off. Then I re-installed OJS via the web interface, re-created my demo journal, enabled the plugin and ran the upgrade script, went to email form and clicked send. Again it skipped right over my callback, which I have now edited to throw a fatal error if it ever gets called, but it does not.

Here is a link to the entire php error log after the above steps:

Further attempts to trigger the callback have added nothing to the log.

-Thanks

@ChanOmegaWebDesign,

Did you tried to lint your plugin PHP files?

Cheers,
Bruno

Fixed

In version.xml I deleted the lazyload tags and replaced with sitewide tags. Then I ran the upgrade script again. Now the callback works.

Thanks for all the help!
Arleigh

Hi @ChanOmegaWebDesign,

Good sleuthing; glad to know it’s working.

Regards,
Alec Smecher
Public Knowledge Project Team