Skip to content

Commit

Permalink
Merge pull request #566 from humanmade/backport-562-to-v18-branch
Browse files Browse the repository at this point in the history
[Backport v18-branch] Ensure Spyc is available
  • Loading branch information
mikelittle authored Mar 7, 2024
2 parents e447b34 + 759ea3b commit 7b159a7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ function parse_file( string $file, string $root ) : Page {
$meta = [];
preg_match( '#^---(.+)---\n+#Us', $raw, $yaml_matches );
if ( $yaml_matches ) {
// This library seems to have problems with its autoload configuration
// sometimes so we need to ensure it's available.
if ( ! class_exists( 'Spyc' ) ) {
require_once Altis\ROOT_DIR . '/vendor/mustangostang/spyc/Spyc.php';
}
$meta = Spyc::YAMLLoadString( $yaml_matches[1] );
// Strip YAML doc from the header.
$raw = substr( $raw, strlen( $yaml_matches[0] ) );
Expand Down

0 comments on commit 7b159a7

Please sign in to comment.