{"action":"created","comment":{"url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/comments/53790380","id":53790380,"diff_hunk":"@@ -124,6 +124,29 @@ public function loadSource($source) {\n \t\t\treturn;\n \t\t}\n \n+        $filterFunction = null;\n+        if (isset($source['filterCallback'])) {\n+            if (!is_callable($source['filterCallback'])) {\n+                SimpleSAML_Logger::debug('Invalid filter callback ' . $source['filterCallback'] . ' - attempting to re-use cached metadata');\n+                $this->addCachedMetadata($source);\n+                return;\n+            } else {\n+                $filterFunction = $source['filterCallback'];\n+            }\n+        }\n+\n+        if(isset($source['filterFactory'])) {\n+            if (isset($filterFunction)) {\n+                SimpleSAML_Logger::warning(\"Both 'filterCallback' and 'filterFactory' defined. Ignoring 'filterFactory\");\n+            } elseif (is_callable($source['filterFactory'])) {\n+                $filterFunction = call_user_func_array($source['filterFactory'], $source['filterFactoryArgs']);\n+            } else {\n+                SimpleSAML_Logger::debug('Invalid filter factory ' . $source['filterFactory'] . ' - attempting to re-use cached metadata');","path":"modules/metarefresh/lib/MetaLoader.php","position":21,"original_position":21,"commit_id":"61b3d0a3e9612e1d40f9c4cf69023edd3a38c07c","original_commit_id":"61b3d0a3e9612e1d40f9c4cf69023edd3a38c07c","user":{"login":"jaimeperez","id":1942728,"avatar_url":"https://avatars.githubusercontent.com/u/1942728?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimeperez","html_url":"https://github.com/jaimeperez","followers_url":"https://api.github.com/users/jaimeperez/followers","following_url":"https://api.github.com/users/jaimeperez/following{/other_user}","gists_url":"https://api.github.com/users/jaimeperez/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimeperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimeperez/subscriptions","organizations_url":"https://api.github.com/users/jaimeperez/orgs","repos_url":"https://api.github.com/users/jaimeperez/repos","events_url":"https://api.github.com/users/jaimeperez/events{/privacy}","received_events_url":"https://api.github.com/users/jaimeperez/received_events","type":"User","site_admin":false},"body":"Same here.","created_at":"2016-02-23T14:56:32Z","updated_at":"2016-02-23T14:56:32Z","html_url":"https://github.com/simplesamlphp/simplesamlphp/pull/288#discussion_r53790380","pull_request_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288","_links":{"self":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/comments/53790380"},"html":{"href":"https://github.com/simplesamlphp/simplesamlphp/pull/288#discussion_r53790380"},"pull_request":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288"}}},"pull_request":{"url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288","id":51023721,"html_url":"https://github.com/simplesamlphp/simplesamlphp/pull/288","diff_url":"https://github.com/simplesamlphp/simplesamlphp/pull/288.diff","patch_url":"https://github.com/simplesamlphp/simplesamlphp/pull/288.patch","issue_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/288","number":288,"state":"open","locked":false,"title":"Filtering function in MetaLoader","user":{"login":"pradtke","id":932934,"avatar_url":"https://avatars.githubusercontent.com/u/932934?v=3","gravatar_id":"","url":"https://api.github.com/users/pradtke","html_url":"https://github.com/pradtke","followers_url":"https://api.github.com/users/pradtke/followers","following_url":"https://api.github.com/users/pradtke/following{/other_user}","gists_url":"https://api.github.com/users/pradtke/gists{/gist_id}","starred_url":"https://api.github.com/users/pradtke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradtke/subscriptions","organizations_url":"https://api.github.com/users/pradtke/orgs","repos_url":"https://api.github.com/users/pradtke/repos","events_url":"https://api.github.com/users/pradtke/events{/privacy}","received_events_url":"https://api.github.com/users/pradtke/received_events","type":"User","site_admin":false},"body":"Testable with:\r\n\r\nphpunit --configuration tools/phpunit tests/modules/metarefresh/lib/MetaLoaderTest.php\r\n\r\nChange is add ability to filter entities by a callback function (or a currying function).  The main use case is filtering metadata that has eduGain entities by the registration authority.\r\n\r\n'source' can now take new keys:\r\n\r\n'filterCallback' is the name of a function that accepts a 'SimpleSAML_Metadata_SAMLParser' and returns true/false\r\n\r\n'filterFactory' is the name of a function that returns a function that meets the requirements of 'filterCallback'.   'filterFactoryArgs' is an array of arguments passed to the factory function.\r\n\r\n-----------------------------------------------------------------\r\nOne thing I could not figure out was how to enable the metarefresh module for unit test.  Jamie described a technique in https://groups.google.com/d/msg/simplesamlphp-dev/Sp0Hhe86KTQ/pzY6LubrAAAJ however (because of lack of php and simplesaml experience) I couldn't get to work.  For short term I added an ENV variable to load all modules and that ENV gets set by phpunit. I will need some help on this part if we want to use a different technique.\r\n\r\nIf we have some agreement on the new attribute names and the functionality then I can work on updating the docs in a subsequent PR\r\n\r\nLastly, my co-worker pointed out that the filtering is happening post XML processing/conversion to entities which is not memory efficient. It might be desirable to move filtering into the SimpleSaml SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement() call or to have that call return a generator so that only one entity is converted/filtered at a time.\r\n","created_at":"2015-11-17T23:58:39Z","updated_at":"2016-02-23T14:56:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6646d7e6aa5f4c965fc6f0f00dbe3dc81b22290d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288/commits","review_comments_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288/comments","review_comment_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/288/comments","statuses_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/statuses/61b3d0a3e9612e1d40f9c4cf69023edd3a38c07c","head":{"label":"pradtke:feature/callback-metadata-filter","ref":"feature/callback-metadata-filter","sha":"61b3d0a3e9612e1d40f9c4cf69023edd3a38c07c","user":{"login":"pradtke","id":932934,"avatar_url":"https://avatars.githubusercontent.com/u/932934?v=3","gravatar_id":"","url":"https://api.github.com/users/pradtke","html_url":"https://github.com/pradtke","followers_url":"https://api.github.com/users/pradtke/followers","following_url":"https://api.github.com/users/pradtke/following{/other_user}","gists_url":"https://api.github.com/users/pradtke/gists{/gist_id}","starred_url":"https://api.github.com/users/pradtke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradtke/subscriptions","organizations_url":"https://api.github.com/users/pradtke/orgs","repos_url":"https://api.github.com/users/pradtke/repos","events_url":"https://api.github.com/users/pradtke/events{/privacy}","received_events_url":"https://api.github.com/users/pradtke/received_events","type":"User","site_admin":false},"repo":{"id":46382300,"name":"simplesamlphp","full_name":"pradtke/simplesamlphp","owner":{"login":"pradtke","id":932934,"avatar_url":"https://avatars.githubusercontent.com/u/932934?v=3","gravatar_id":"","url":"https://api.github.com/users/pradtke","html_url":"https://github.com/pradtke","followers_url":"https://api.github.com/users/pradtke/followers","following_url":"https://api.github.com/users/pradtke/following{/other_user}","gists_url":"https://api.github.com/users/pradtke/gists{/gist_id}","starred_url":"https://api.github.com/users/pradtke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradtke/subscriptions","organizations_url":"https://api.github.com/users/pradtke/orgs","repos_url":"https://api.github.com/users/pradtke/repos","events_url":"https://api.github.com/users/pradtke/events{/privacy}","received_events_url":"https://api.github.com/users/pradtke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pradtke/simplesamlphp","description":"SimpleSAMLphp is an award-winning application written in native PHP that deals with authentication.","fork":true,"url":"https://api.github.com/repos/pradtke/simplesamlphp","forks_url":"https://api.github.com/repos/pradtke/simplesamlphp/forks","keys_url":"https://api.github.com/repos/pradtke/simplesamlphp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pradtke/simplesamlphp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pradtke/simplesamlphp/teams","hooks_url":"https://api.github.com/repos/pradtke/simplesamlphp/hooks","issue_events_url":"https://api.github.com/repos/pradtke/simplesamlphp/issues/events{/number}","events_url":"https://api.github.com/repos/pradtke/simplesamlphp/events","assignees_url":"https://api.github.com/repos/pradtke/simplesamlphp/assignees{/user}","branches_url":"https://api.github.com/repos/pradtke/simplesamlphp/branches{/branch}","tags_url":"https://api.github.com/repos/pradtke/simplesamlphp/tags","blobs_url":"https://api.github.com/repos/pradtke/simplesamlphp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pradtke/simplesamlphp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pradtke/simplesamlphp/git/refs{/sha}","trees_url":"https://api.github.com/repos/pradtke/simplesamlphp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pradtke/simplesamlphp/statuses/{sha}","languages_url":"https://api.github.com/repos/pradtke/simplesamlphp/languages","stargazers_url":"https://api.github.com/repos/pradtke/simplesamlphp/stargazers","contributors_url":"https://api.github.com/repos/pradtke/simplesamlphp/contributors","subscribers_url":"https://api.github.com/repos/pradtke/simplesamlphp/subscribers","subscription_url":"https://api.github.com/repos/pradtke/simplesamlphp/subscription","commits_url":"https://api.github.com/repos/pradtke/simplesamlphp/commits{/sha}","git_commits_url":"https://api.github.com/repos/pradtke/simplesamlphp/git/commits{/sha}","comments_url":"https://api.github.com/repos/pradtke/simplesamlphp/comments{/number}","issue_comment_url":"https://api.github.com/repos/pradtke/simplesamlphp/issues/comments{/number}","contents_url":"https://api.github.com/repos/pradtke/simplesamlphp/contents/{+path}","compare_url":"https://api.github.com/repos/pradtke/simplesamlphp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pradtke/simplesamlphp/merges","archive_url":"https://api.github.com/repos/pradtke/simplesamlphp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pradtke/simplesamlphp/downloads","issues_url":"https://api.github.com/repos/pradtke/simplesamlphp/issues{/number}","pulls_url":"https://api.github.com/repos/pradtke/simplesamlphp/pulls{/number}","milestones_url":"https://api.github.com/repos/pradtke/simplesamlphp/milestones{/number}","notifications_url":"https://api.github.com/repos/pradtke/simplesamlphp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pradtke/simplesamlphp/labels{/name}","releases_url":"https://api.github.com/repos/pradtke/simplesamlphp/releases{/id}","deployments_url":"https://api.github.com/repos/pradtke/simplesamlphp/deployments","created_at":"2015-11-17T23:32:27Z","updated_at":"2015-11-17T23:32:30Z","pushed_at":"2015-12-02T19:45:30Z","git_url":"git://github.com/pradtke/simplesamlphp.git","ssh_url":"git@github.com:pradtke/simplesamlphp.git","clone_url":"https://github.com/pradtke/simplesamlphp.git","svn_url":"https://github.com/pradtke/simplesamlphp","homepage":null,"size":10649,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"simplesamlphp:master","ref":"master","sha":"138be1e778a61be9774d346af08d8e71e724885a","user":{"login":"simplesamlphp","id":5774640,"avatar_url":"https://avatars.githubusercontent.com/u/5774640?v=3","gravatar_id":"","url":"https://api.github.com/users/simplesamlphp","html_url":"https://github.com/simplesamlphp","followers_url":"https://api.github.com/users/simplesamlphp/followers","following_url":"https://api.github.com/users/simplesamlphp/following{/other_user}","gists_url":"https://api.github.com/users/simplesamlphp/gists{/gist_id}","starred_url":"https://api.github.com/users/simplesamlphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simplesamlphp/subscriptions","organizations_url":"https://api.github.com/users/simplesamlphp/orgs","repos_url":"https://api.github.com/users/simplesamlphp/repos","events_url":"https://api.github.com/users/simplesamlphp/events{/privacy}","received_events_url":"https://api.github.com/users/simplesamlphp/received_events","type":"Organization","site_admin":false},"repo":{"id":17167136,"name":"simplesamlphp","full_name":"simplesamlphp/simplesamlphp","owner":{"login":"simplesamlphp","id":5774640,"avatar_url":"https://avatars.githubusercontent.com/u/5774640?v=3","gravatar_id":"","url":"https://api.github.com/users/simplesamlphp","html_url":"https://github.com/simplesamlphp","followers_url":"https://api.github.com/users/simplesamlphp/followers","following_url":"https://api.github.com/users/simplesamlphp/following{/other_user}","gists_url":"https://api.github.com/users/simplesamlphp/gists{/gist_id}","starred_url":"https://api.github.com/users/simplesamlphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simplesamlphp/subscriptions","organizations_url":"https://api.github.com/users/simplesamlphp/orgs","repos_url":"https://api.github.com/users/simplesamlphp/repos","events_url":"https://api.github.com/users/simplesamlphp/events{/privacy}","received_events_url":"https://api.github.com/users/simplesamlphp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simplesamlphp/simplesamlphp","description":"SimpleSAMLphp is an award-winning application written in native PHP that deals with authentication.","fork":false,"url":"https://api.github.com/repos/simplesamlphp/simplesamlphp","forks_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/forks","keys_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/teams","hooks_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/hooks","issue_events_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/events{/number}","events_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/events","assignees_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/assignees{/user}","branches_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/branches{/branch}","tags_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/tags","blobs_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/git/refs{/sha}","trees_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/statuses/{sha}","languages_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/languages","stargazers_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/stargazers","contributors_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/contributors","subscribers_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/subscribers","subscription_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/subscription","commits_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/commits{/sha}","git_commits_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/git/commits{/sha}","comments_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/comments{/number}","issue_comment_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/comments{/number}","contents_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/contents/{+path}","compare_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/merges","archive_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/downloads","issues_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues{/number}","pulls_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls{/number}","milestones_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/milestones{/number}","notifications_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/labels{/name}","releases_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/releases{/id}","deployments_url":"https://api.github.com/repos/simplesamlphp/simplesamlphp/deployments","created_at":"2014-02-25T09:01:45Z","updated_at":"2016-02-23T08:20:13Z","pushed_at":"2016-02-22T14:49:48Z","git_url":"git://github.com/simplesamlphp/simplesamlphp.git","ssh_url":"git@github.com:simplesamlphp/simplesamlphp.git","clone_url":"https://github.com/simplesamlphp/simplesamlphp.git","svn_url":"https://github.com/simplesamlphp/simplesamlphp","homepage":null,"size":13717,"stargazers_count":208,"watchers_count":208,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":177,"mirror_url":null,"open_issues_count":82,"forks":177,"open_issues":82,"watchers":208,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288"},"html":{"href":"https://github.com/simplesamlphp/simplesamlphp/pull/288"},"issue":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/288"},"comments":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/issues/288/comments"},"review_comments":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288/comments"},"review_comment":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/pulls/288/commits"},"statuses":{"href":"https://api.github.com/repos/simplesamlphp/simplesamlphp/statuses/61b3d0a3e9612e1d40f9c4cf69023edd3a38c07c"}}}}