1

我正在尝试将 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 

4

1 回答 1

0

它本身就是一个很大的桃子编译器。

https://github.com/peachpiecompiler/peachpie/issues/957

您要么从 php 脚本中删除失败的代码,要么等待 peachpie 的下一个版本。

于 2021-06-11T18:27:53.593 回答