【问题标题】:PeachPie error when using the WPGraphQL plugin for WordPress使用 WordPress 的 WPGraphQL 插件时出现 PeachPie 错误
【发布时间】:2021-06-10 21:23:15
【问题描述】:

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

关于它在我的解决方案中的外观,我添加了 screenshot of my Solution Explorer

当设置与此 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 

【问题讨论】:

    标签: c# php wordpress peachpie


    【解决方案1】:

    peachpie 编译器本身就是一个大人物。

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

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

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 2017-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-07-04
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      • 2014-03-20
      相关资源
      最近更新 更多