Skip to content

Commit

Permalink
Tweaks to changes & documentation. Removed remaining TODO.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benaka Moorthi committed Jun 8, 2013
1 parent 8fb4ebc commit 847fc4d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
27 changes: 20 additions & 7 deletions core/PluginsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ class Piwik_PluginsManager
/**
* Array of observers (callbacks attached to events) that are not methods
* of plugin classes.
*
* @var array
*/
private $extraObservers = array();

/**
* TODO
* Array storing information for all pending events. Each item in the array
* will be an array w/ two elements:
*
* array(
* 'Event.Name', // the event name
* array('event', 'parameters') // the parameters to pass to event observers
* )
*
* @var array
*/
private $pendingEvents = array();

Expand Down Expand Up @@ -626,10 +636,12 @@ private function installPluginIfNecessary(Piwik_Plugin $plugin)
*
* @param string $eventName The name of the event, ie, API.getReportMetadata.
* @param array $params The parameters to pass to each callback when executing.
* @param bool $pending Whether this posted event should be posted again for
* plugins loaded after the event is fired.
* @param bool $pending Whether this event should be posted again for plugins
* loaded after the event is fired.
* @param array|null $plugins The plugins to post events to. If null, the event
* is posted to all events.
* is posted to all plugins. The elements of this array
* can be either the Piwik_Plugin objects themselves
* or their string names.
*/
public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
Expand All @@ -645,6 +657,10 @@ public function postEvent($eventName, $params, $pending = false, $plugins = null

// collect all callbacks to execute
foreach ($plugins as $plugin) {
if (is_string($plugin)) {
$plugin = $this->getLoadedPlugin($plugin);
}

if (!$this->isPluginActivated($plugin->getPluginName())) {
continue;
}
Expand Down Expand Up @@ -760,9 +776,6 @@ function __construct($pluginName, $message)
}
}

// TODO: test pending events & addaction events
// TODO: get tests to pass.
// TODO: test all of Piwik.
/**
* Post an event to the dispatcher which will notice the observers.
*
Expand Down
4 changes: 2 additions & 2 deletions core/Tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public static function connectPiwikTrackerDb()
$configDb['port'] = '3306';
}

Piwik_PostEvent('Tracker.getDatabaseConfig', array($configDb));
Piwik_PostEvent('Tracker.getDatabaseConfig', array(&$configDb));

$db = self::factory($configDb);
$db->connect();
Expand All @@ -505,7 +505,7 @@ public static function connectDatabaseIfNotConnected()

try {
$db = null;
Piwik_PostEvent('Tracker.createDatabase', array(&$db)); // TODO: test installation.
Piwik_PostEvent('Tracker.createDatabase', array(&$db));
if (is_null($db)) {
$db = self::connectPiwikTrackerDb();
}
Expand Down
2 changes: 1 addition & 1 deletion core/Tracker/Visit.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ protected function handleKnownVisit($idActionUrl, $idActionName, $actionType, $v
. " wasn't found in the DB, we fallback to a new visitor");
}

Piwik_PostEvent('Tracker.knownVisitorInformation', array(&$this->visitorInfo)); // TODO: check all PostEvent changes for whether first arg should be reference or not
Piwik_PostEvent('Tracker.knownVisitorInformation', array(&$this->visitorInfo));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion misc/log-analytics/import_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def _call_api(method, **kwargs):
try:
return json.loads(res)
except ValueError:
raise urllib2.URLError('Piwik returned an invalid response: ' + res)
raise urllib2.URLError('Piwik returned an invalid response: ' + res[:300])


@staticmethod
Expand Down

0 comments on commit 847fc4d

Please sign in to comment.