{"action":"created","issue":{"url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/16","labels_url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/16/comments","events_url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/16/events","html_url":"https://github.com/backdrop-contrib/redirect/issues/16","id":106851917,"number":16,"title":"Changing an alias causes a Fatal error on 1.2.0: ","user":{"login":"quicksketch","id":100206,"avatar_url":"https://avatars.githubusercontent.com/u/100206?v=3","gravatar_id":"","url":"https://api.github.com/users/quicksketch","html_url":"https://github.com/quicksketch","followers_url":"https://api.github.com/users/quicksketch/followers","following_url":"https://api.github.com/users/quicksketch/following{/other_user}","gists_url":"https://api.github.com/users/quicksketch/gists{/gist_id}","starred_url":"https://api.github.com/users/quicksketch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quicksketch/subscriptions","organizations_url":"https://api.github.com/users/quicksketch/orgs","repos_url":"https://api.github.com/users/quicksketch/repos","events_url":"https://api.github.com/users/quicksketch/events{/privacy}","received_events_url":"https://api.github.com/users/quicksketch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-16T20:03:40Z","updated_at":"2015-09-16T20:05:47Z","closed_at":null,"body":"This was originally filed against core in https://github.com/backdrop/backdrop-issues/issues/1203.\r\n\r\n```\r\nRecoverable fatal error: Argument 1 passed to filter_entity_insert() must implement interface EntityInterface, instance of stdClass given in filter_entity_insert() (line 1506 of /backdrop/core/modules/filter/filter.module).\r\n```\r\n\r\nSteps to reproduce:\r\n1) create a node (with no alias)\r\n2) set up automatic aliasing for that node type\r\n3) edit the node, check the box for an automatic alias, save\r\n4) edit the node again, uncheck the box for an automatic alias, change the alias, save\r\n5) error.\r\n"},"comment":{"url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/comments/140870989","html_url":"https://github.com/backdrop-contrib/redirect/issues/16#issuecomment-140870989","issue_url":"https://api.github.com/repos/backdrop-contrib/redirect/issues/16","id":140870989,"user":{"login":"quicksketch","id":100206,"avatar_url":"https://avatars.githubusercontent.com/u/100206?v=3","gravatar_id":"","url":"https://api.github.com/users/quicksketch","html_url":"https://github.com/quicksketch","followers_url":"https://api.github.com/users/quicksketch/followers","following_url":"https://api.github.com/users/quicksketch/following{/other_user}","gists_url":"https://api.github.com/users/quicksketch/gists{/gist_id}","starred_url":"https://api.github.com/users/quicksketch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quicksketch/subscriptions","organizations_url":"https://api.github.com/users/quicksketch/orgs","repos_url":"https://api.github.com/users/quicksketch/repos","events_url":"https://api.github.com/users/quicksketch/events{/privacy}","received_events_url":"https://api.github.com/users/quicksketch/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T20:05:47Z","updated_at":"2015-09-16T20:05:47Z","body":"The source of this problem is the call to `redirect_save()` takes a stdClass object:\r\n\r\n```\r\n    $redirect = new stdClass();\r\n    redirect_object_prepare($redirect);\r\n    $redirect->source = $path['original']['alias'];\r\n    $redirect->redirect = $path['source'];\r\n    $redirect->language = $path['original']['langcode'];\r\n    // Check if the redirect exists before saving.\r\n    $hash = redirect_hash($redirect);\r\n    if (!redirect_load_by_hash($hash)) {\r\n      redirect_save($redirect);\r\n    }\r\n```\r\n\r\nBut then later it calls all these hook, allowing the redirect to be modified:\r\n\r\n```\r\n    // Allow other modules to alter the redirect before saving.\r\n    module_invoke_all('redirect_presave', $redirect);\r\n    module_invoke_all('entity_presave', $redirect, 'redirect');\r\n\r\n    // Save the redirect to the database and invoke the post-save hooks.\r\n    if ($redirect->is_new) {\r\n      backdrop_write_record('redirect', $redirect);\r\n      module_invoke_all('redirect_insert', $redirect);\r\n      module_invoke_all('entity_insert', $redirect, 'redirect');\r\n    }\r\n    else {\r\n      backdrop_write_record('redirect', $redirect, array('rid'));\r\n      module_invoke_all('redirect_update', $redirect);\r\n      module_invoke_all('entity_update', $redirect, 'redirect');\r\n    }\r\n```\r\n\r\nBut when calling `hook_entity_update()`, redirect is passing in a stdClass object instead of a an Entity class. Since redirects aren't entities, I think it would be reasonable to remove these calls to hook_entity_update/insert/presave(). "}}