c# - 使用 WordPress 的 WPGraphQL 插件时出现 PeachPie 错误
问题描述
我正在尝试将 WPGraphQL 插件用于 WordPress 和 PeachPie。我使用 Visual Studio 2019 解决方案构建了它,其中包含两个基于 ASP.NET Core Empty 模板的项目,目标框架设置为 .NET 5.0。
我已经成功设置了一个使用默认 Nuget 包 PeachPied.WordPress.AspNetCore 的初始项目。它运行正常,并按预期呈现 WordPress 页面。第一个的项目文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PeachPied.WordPress.AspNetCore" Version="5.7.1-preview7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins\Plugins.msbuildproj" />
</ItemGroup>
</Project>
另外,我在同一个解决方案下建立了第二个项目,我已经加载了插件以与第一个项目一起使用。第二个项目是第一个项目的依赖项。第二个项目文件如下所示:
<Project Sdk="PeachPied.WordPress.Build.Plugin/5.7.1-preview7">
<PropertyGroup>
<WpContentTarget>
</WpContentTarget>
<PhpRelativePath>wp-content/</PhpRelativePath>
</PropertyGroup>
</Project>
对于它在我的解决方案中的外观,我包含了我的解决方案资源管理器的屏幕截图。
当设置与此 GitHub 项目相同的方式时,我能够使用 HelloDolly 插件成功测试插件项目:https ://github.com/iolevel/peachpie-wordpress 。
但是,在尝试使用 WPGraphQL 插件时,我遇到了以下错误。它在构建/调试项目时显示此错误。
Unable to cast object of type 'Pchp.CodeAnalysis.Semantics.BoundArrayEx' to type 'Pchp.CodeAnalysis.Semantics.BoundReferenceExpression'.
at Pchp.CodeAnalysis.Semantics.BoundListEx.<>c.<.ctor>b__22_0(KeyValuePair`2 pair)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
at Pchp.CodeAnalysis.Semantics.BoundListEx..ctor(IEnumerable`1 items)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindArrayEx(ArrayEx x, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindAssignEx(AssignEx expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatementCore(Statement stmt)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatement(Statement stmt)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindWholeStatement(Statement stmt)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitExpressionStmt(ExpressionStmt x)
at Devsense.PHP.Syntax.Ast.ExpressionStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Devsense.PHP.Syntax.TreeVisitor.VisitList[T](IList`1 items)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitBlockStmt(BlockStmt x)
at Devsense.PHP.Syntax.Ast.BlockStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitForeachStmt(ForeachStmt x)
at Devsense.PHP.Syntax.Ast.ForeachStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Pchp.CodeAnalysis.EnumeratorExtension.ForEach[T](IEnumerable`1 enumerable, Action`1 func)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor..ctor(IList`1 statements, SemanticsBinder binder)
at Pchp.CodeAnalysis.Symbols.SourceRoutineSymbol.get_ControlFlowGraph()
at Pchp.CodeAnalysis.SourceCompiler.EnqueueRoutine(SourceRoutineSymbol routine)
at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>) Plugins C:\Users\curritl\.nuget\packages\peachpie.net.sdk\1.0.5\build\Peachpie.NET.Core.Sdk.targets 245
解决方案
它本身就是一个很大的桃子编译器。
https://github.com/peachpiecompiler/peachpie/issues/957
您要么从 php 脚本中删除失败的代码,要么等待 peachpie 的下一个版本。
推荐阅读
- r - 收听列表中的响应式
- mysql - 用于 MySQL 的 Azure 数据库 - 缓慢的大量插入
- c# - 读取没有互操作的 Excel 宏
- php - zf3 监听另一个类中触发的事件
- python - 有人可以解释为什么 print("red" == "blue" or 3 >= 3) 返回 True
- r - 运行过滤器 pandoc-citeproc 时出错:找不到可执行的 pandoc-citeproc
- bash - 无法在函数中执行 awk 命令,但直接在 shell 中工作
- octave - 解决不等式让 CRootOf 得到答案
- ios - 在 SwiftUI 视图中结合 onChange 和 onAppear 事件?
- python - SQLAlchemy 查询将相关数据的伪列添加为字典数组