Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kingandpartners/elastic-press int…
Browse files Browse the repository at this point in the history
…o nuxt-press-updates-2
  • Loading branch information
jGRUBBS committed Apr 30, 2024
2 parents 0951455 + 24d0b9a commit 70d98a2
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 13 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Trigger Satis Build

on:
- release
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: kingandpartners/dispatch-workflow@main
with:
token: ${{ secrets.KINGMACHINE_WORKFLOW_TOKEN }}
repo: kingandpartners/kingandpartners-composer
workflow_id: partial-build.yml
inputs: '{"package_name": "kingandpartners/elastic-press"}'
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# CHANGELOG

[Releases](https://github.com/kingandpartners/elastic-press/releases/)

## `v0.8.1`
- #15 [bulletproofing] acf.php... fix parse_acf_field for falsy value handling
- #16 [bulletproofing] acf.php... fix layout index search

## `v0.8.0`
- [ ] #13 fixes Elasticsearch "Limit of total fields in index" exception

### Upgrade Notes
- [ ] if needed, update the limit with `ep_settings` hook
- see https://github.com/kingandpartners/nemacolin/pull/1450 for example

## `branch-es-settings-filter` branch (AKA Pretend "v0.7.0")
- based off `es-settings-filter` branch as of 1a10a02
- same changes as in `v0.8.0` but in separate branch

## `v0.6.0`
- based off `master`, no code changes with `branch-es-signed-request`
- only introduces merge commits

## `branch-es-signed-request` branch (aka pretend "v0.5.0")
- based off `es-signed-request` branch as of 261da7b



39 changes: 33 additions & 6 deletions includes/acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@
* @return mixed $value
*/
function parse_acf_field( $field, $value, $data = array(), $base_prefix = '' ) {
switch ( $field['type'] ) {
//
// NOTE:
// If $field is false or doesn't have 'type' key
// we skip the switch statement and return the original $value
// down below
//
$field_type = false;
if ($field && array_key_exists('type', $field) ) {
$field_type = $field['type'];
}

switch ( $field_type ) {
// The default `image` metadata is just the attachment id
// the image array is much more useful.
case 'image':
Expand Down Expand Up @@ -75,10 +86,21 @@ function parse_acf_field( $field, $value, $data = array(), $base_prefix = '' ) {
case 'flexible_content':
if (!getenv('ES_SKIP_ACF_PARSING')) {
$data = array();

foreach ( $value as $index => $m ) {
$layout_idx = array_search( $m['acf_fc_layout'], array_column( $field['layouts'], 'name' ) );
$layout = $field['layouts'][ $layout_idx ];
$idx = 0;
// keys in $field['layouts'] could be integer or string like "layout_62c81b294f5d7"
// so we have to search the layout objects themselves to get the
// correctly returned key/index
$layout_map = array_map(
function($field_layout) {
return $field_layout['name'];
},
$field['layouts']
);
$layout_idx = array_search( $m['acf_fc_layout'], $layout_map);
$layout = $field['layouts'][ $layout_idx ];
$idx = 0;

foreach ( $m as $k => $mod ) {
if ( 'acf_fc_layout' === $k ) {
continue;
Expand All @@ -95,10 +117,15 @@ function parse_acf_field( $field, $value, $data = array(), $base_prefix = '' ) {
}
$f = acf_get_field( $key );
}
if ( 'clone' === $f['type'] ) {

// Note: `acf_get_field` may not find $key,
// so check $f for false/null values
if ( $f && array_key_exists('type', $f) && 'clone' === $f['type'] ) {
$f = $f['sub_fields'][ $idx ];
}
$data[ $index ][ $k ] = parse_acf_field( $f, $mod, $data, $base_prefix );

$parsed_value = parse_acf_field( $f, $mod, $data, $base_prefix );
$data[ $index ][ $k ] = $parsed_value;
$idx++;
}
$data[ $index ]['acf_fc_layout'] = $m['acf_fc_layout'];
Expand Down
16 changes: 9 additions & 7 deletions includes/elasticsearch/class-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,18 @@ public static function update_write_aliases() {
),
);
$mappings = apply_filters( 'ep_mappings', $mappings, $index_type );
$settings = array(
'mapping' => array(
'total_fields' => array(
'limit' => 10000,
),
),
);
$settings = apply_filters( 'ep_settings', $settings, $index_type );
$params = array(
'index' => $new_index,
'body' => array(
'settings' => array(
'mapping' => array(
'total_fields' => array(
'limit' => 10000,
),
),
),
'settings' => $settings,
'mappings' => array(
'jsondata' => $mappings,
),
Expand Down

0 comments on commit 70d98a2

Please sign in to comment.