Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use correct config #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions class.AttachmentPreviewPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ public function __construct($id) {
self::$instance = $this;
}

//we use this to save the correct config in the bootstrap method
//and override the buggy getConfig() from osticket
static $_correctConfig = null;

/**
* We override the getConfig method, because on
* OsTicket 1.7.5 (at least) the getConfig does only
* return the correct config in the bootstrap method.
* On all other occasions, it will return the default
* config.
* @param PluginInstance|null $instance
* @param $defaults
* @return mixed|null
*/
public function getConfig(PluginInstance $instance = null, $defaults = [])
{
if (self::$_correctConfig) {
return self::$_correctConfig;
}
return parent::getConfig($instance, $defaults);
}

/**
* Replacing the register_shutdown_function's anonymous use of $this with the
* object's destructor for PHP5.3 compatibility
Expand Down Expand Up @@ -96,6 +118,8 @@ static function getInstanceStatic() {
* @see Plugin::bootstrap()
*/
function bootstrap() {
//fix: save correct config, which works only here in bootstrap
self::$_correctConfig = $this->getConfig();
// Ensure plugin does not run during cli cron calls. There is no DOM to manipulate in CLI mode.
if (php_sapi_name() == 'cli') {
return;
Expand Down