@@ -40,10 +40,6 @@ public function checkOwnableUserAccess(Model&OwnableInterface $ownable, string|P
40
40
$ ownerField = $ ownable ->getOwnerFieldName ();
41
41
$ ownableFieldVal = $ ownable ->getAttribute ($ ownerField );
42
42
43
- if (is_null ($ ownableFieldVal )) {
44
- throw new InvalidArgumentException ("{$ ownerField } field used but has not been loaded " );
45
- }
46
-
47
43
$ isOwner = $ user ->id === $ ownableFieldVal ;
48
44
$ hasRolePermission = $ allRolePermission || ($ isOwner && $ ownRolePermission );
49
45
@@ -144,10 +140,10 @@ public function restrictEntityRelationQuery(Builder $query, string $tableName, s
144
140
/** @var Builder $query */
145
141
$ query ->where ($ tableDetails ['entityTypeColumn ' ], '!= ' , $ pageMorphClass )
146
142
->orWhereExists (function (QueryBuilder $ query ) use ($ tableDetails , $ pageMorphClass ) {
147
- $ query ->select ('id ' )->from ('pages ' )
148
- ->whereColumn ('pages.id ' , '= ' , $ tableDetails ['tableName ' ] . '. ' . $ tableDetails ['entityIdColumn ' ])
143
+ $ query ->select ('page_id ' )->from ('entity_page_data ' )
144
+ ->whereColumn ('entity_page_data.page_id ' , '= ' , $ tableDetails ['tableName ' ] . '. ' . $ tableDetails ['entityIdColumn ' ])
149
145
->where ($ tableDetails ['tableName ' ] . '. ' . $ tableDetails ['entityTypeColumn ' ], '= ' , $ pageMorphClass )
150
- ->where ('pages .draft ' , '= ' , false );
146
+ ->where ('entity_page_data .draft ' , '= ' , false );
151
147
});
152
148
});
153
149
}
0 commit comments