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: prevent misuse of get_node() method #10

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Newspack_Network\Incoming_Events;

use Newspack_Network\Accepted_Actions;
use Newspack_Network\Site_Role;
use Newspack_Network\Debugger;
use Newspack_Network\Hub\Nodes;
use Newspack_Network\Hub\Node;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function get_site() {
* Returns the data for this event
*
* @return array
*/
*/
public function get_data() {
return $this->data;
}
Expand Down Expand Up @@ -139,8 +140,13 @@ public function is_local() {
* Get this event's Node object. Will only work on the Hub
*
* @return ?Node
*
* @throws \Exception If the function was called from a node.
*/
public function get_node() {
if ( Site_Role::is_node() ) {
throw new \Exception( 'This function can only be called from the Hub' );
}
return Nodes::get_node_by_url( $this->site );
}

Expand Down