2017 © Pedro Peláez
 

elgg-plugin elgg_scalarmd

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not

image

beck24/elgg_scalarmd

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not

  • Friday, March 10, 2017
  • by beck24
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

elgg_scalarmd

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not., (*1)

This is useful for situations where you are expecting a string, and only a string, and an accidental array return would break things. An example might be a webservices response that requires a string., (*2)

This is a workaround for https://github.com/Elgg/Elgg/issues/4268 where frequently updated metadata can accidentally duplicate into an array. This function ensures a scalar return for the metadata value and will reset the entity metadata to a scalar value by default., (*3)

Caveats

This works for metadata that does not depend on access or ownership, as a simple key/value pair (eg. most metadata usage) If the metadata does depend on access or ownership do not use this function on it or you will surely lose data., (*4)

Usage

Scenario:, (*5)

$entity->country = [
    'canada',
    'canada
];

$entity->country is now:, (*6)

Array
(
    [0] => canada
    [1] => canada
)

Without fixing: \Beck24\scalarmd($entity, 'country', false), (*7)

canada

$entity->country is still:, (*8)

Array
(
    [0] => canada
    [1] => canada
)

Now with fixing: \Beck24\scalarmd($entity, 'country'), (*9)

canada

$entity->country is now:, (*10)

canada

The Versions

10/03 2017

dev-master

9999999-dev http://arckinteractive.com

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not

  Sources   Download

GPL-2.0

The Requires

 

by Matt Beckett

plugin utility elgg workaround bugfix

16/02 2017

1.0.1

1.0.1.0 http://arckinteractive.com

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not

  Sources   Download

GPL-2.0

The Requires

 

by Matt Beckett

plugin utility elgg workaround bugfix