Miva Script is the server side scripting language of the Miva
Merchant shopping cart, but it's uses go much
further. It is especially well suited for web development having built
in support for MySQL, MivaSQL and xBase3 databases.
A typical Miva Script application combines HTML tags, Miva
Script tags and functions; is compiled and uploaded to a web
server running the FREEMiva Merchant Empresa.
You can also run your scripts on your local computer by running the FREEMiva Merchant Mia,
making it very easy to start learning Miva Script right away. Oh and
did we mention the Miva
Script
Compiler is also FREE.
Miva Script tags and functions correspond to typical
programming language constructs. The database, mail, commerce
and new graphics functionality provide a rich set of tools for
application development.
Miva Script is fast. Because it is efficiently coded and
compiled, your server side scripts will execute quicker and your web
pages will display faster providing your users with a better experience.
MS-987: Skipping to previous index record can cause a segfault when no more records exist
MS-986: Asynchronous tasks that call miva_async_sleep after they have timed out wake can run forever
Other Changes
MacOS binaries are now signed and notarized to prevent trusted execution / GateKeeper issues
5.37 Release Notes (11/18/2022)
Bugs Fixed
MS-984: OpenSSL_1_1_x loads functions from the wrong libraries causing failures on Windows
MS-975: XBase3 EOF variable is writeable in certain scenarios
MS-974: ISNULL does not work as expected with XBase variables
MS-971: Special variables need to define their primary value type when they are initially loaded
MS-970: XBaseDatabase totrec, recno, and deleted variables do not properly handle value conversion
MS-969: Remove unused Variable::Element method
MS-967: ConfigurationAggregateVariable does not overload all necessary functions
MS-964: Multiple special variables do not properly evaluate when compared
MS-963: ISNULL s.process_name returns 1 until the value is loaded
MS-962: ProcessNameVariable will return 0 / 0.00 if s.process_name is retrieved as an integer / double
MS-961: dBase and MivaSQL files are limited to 2^31 bytes
MS-959: File functions, both core and API, do not support 64-bit sizes and offsets
MS-957: Variable::value_integer/value_double should not convert the variable when the value is null
MS-954: s.dyn_time_remaining should return 0 when no time is remaining and a timeout is configured
MS-953: MvCALL: Invalid memory access when the URL is blank
MS-950: Add miva_json_encode builtin
MS-949: ImmutableVariable does not override Convert_Aggregate allowing the variable to be converted to another data type
MS-948: Allow POST-ed content errors to be logged to the error syslog
MS-945: MvCAPTURE uses memory inefficiently and is slow when handling large blocks of captured output
MS-944: timezone() is returning -0 for GMT
MS-943: Create new ternary operator type builtin function "ternary( , , )"
MS-941: Commands out of sync error when using MariaDB 10.x
MS-936: A large compiler compatibility flag number can create a buffer overflow
MS-935: Add support for a Ubuntu build system
MS-909: Array does not properly track entry count when using Set
MS-8: UPDATE with index fails to update all records
New Features
Added new "input" option for MvCONFIG_ERROR_SYSLOG. This will cause any input errors such as unknown
POST-ed content type, POST-ed data is too long, etc... to record the error to the system log.
Timeouts caused by the processing of POST-ed data will now be recorded to the system log when the
MvCONFIG_ERROR_SYSLOG contains the "timeout" option.
New Built-in Functions
ternary( condition, if_true, if_false )
Tests the condition to determine whether if_true or if_false should be returned. It should be noted
that the if_true and if_false values will always be evaluated even when the condition is not met, but
only the met condition will be returned.
Parameters:
condition: A value that will be tested
if_true: The value to return when the condition is true
if_false: The value to return when the condition is false
Return Value:
if_true value when condition is true, otherwise the if_false value
miva_json_encode( input var, flags )
Generates a valid JSON formatted blob based on the passed in data
Parameters:
input var: The data that should be encoded. Can be a value, structure, or array.
flags: A comma separated list of the following options:
- pretty: Formats the JSON blob with new lines, tabs, etc..
Return Value:
The generated JSON blob
New API Functions
int mvVariable_IsTrue( mvVariable )
Takes a variable and checks to see if it evaluates to a true value or not
Parameters:
mvVariable variable: The variable to evaluate
Return Value:
1 if true, 0 otherwise
char * mvProgram_JSON_Encode( mvProgram program, mvVariable input, int flags, int *data_length, int *data_size )
Takes a variable and generates a valid JSON formatted blob
Parameters:
mvProgram program: The current MivaVM
mvVariable input: The data that should be encoded
int flags: Flags bitor-ed together; supports flags are MIVA_JSONENCODE_FLAG_PRETTY
int *data_length: Pointer to an integer that will contain the length of the returned data
int *data_size: Pointer to an integer that will contain the size of the memory buffer
Return Value:
Pointer to the generated JSON blob
Other Changes
This release introduces support for Ubuntu 20.x and Apple silicon systems
MacOS systems now uses os_log for its logging events. This replaces the previous syslog logging mechanism.
The log events can now be viewed via the Console application or via the command line "log" program. All logs
will be tagged with a subsystem of "com.miva.empresa". Example on viewing the logs:
log show --predicate "subsystem =\"com.miva.empresa\""
dBase and MivaSQL files now supports files over 2GB
MS-928: FastCGI applications should have a unique value for each request that can be used for logging
MS-927: CentOS8 FastCGI fails to list directories
MS-924: Add miva_array_combine builtin
MS-923: SMTP DATA terminator can be output prior to the DATA command being issued
MS-922: Runtime errors can be output within MvSMTP server connection
MS-920: Transition all build systems to compiling mysql.so against MariaDB header files
MS-918: Prepared statements are not removed from the internal PostgreSQL library connector
MS-916: Copying a NullVariable to a Variable should explicitly set the have_string to 1 and preferred data type to VARDATATYPE_STRING
MS-912: Using a non-numeric LAST / COUNT value for MvFOR / MvFOREACH can cause an infinite loop
New Features
New Built-in Functions
miva_array_combine ( array var, compare_callback, combine_callback, flags, data var )
This function will combine multiple elements within an array into a single element depending on the design of the compare and callback functions
Parameters:
array: The array to iterate
compare_callback: The callback function that determines whether the 2 elements of the array should be combined
combine_callback: The callback function that defines the operation to perform on the 2 elements that are being combined
flags: Flags that dictate how the function behaves
data: Additional data passed to the compare and combine callback functions
Return Value:
The number of elements in the array
Flags:
sorted: The array will be processed as if the elements are sorted in ascending fashion, stopping the comparison of the current element once the next element does not match. If the flag is omitted, the function will do a brute force search across the elements, meaning every element will be checked against every other element in the array.
Example MivaScript code:
Compare_Callback( element1 var, element2 var, data var )
Parameters:
element1: An array element
element2: An array element
data: The data that was passed to miva_array_combine
Return Value:
- 1 if the elements should be combined, 0 otherwise
Combined_Callback( element1 var, element2 var, data var )
Parameters:
element1: An array element
element2: An array element
data: The data that was passed to miva_array_combine
Return Value:
The combined variable made up of element1 and element2
bzip2_compress ( data var, block_size, compressed var )
Compress the data using the bzip2 format
Parameters:
data: The data to be compressed
block_size: The block size to use for the compression (valid values are 1-9; 1 being faster and less efficient compression, 9 being slower and more efficient compression)
compressed: The data compressed in bzip2 format
Return Value:
1 on success, 0 on failure
bzip2_decompress ( compressed var, decompressed )
Decompress the data using the bzip2 format
Parameters:
compressed: The compressed bzip2 data
decompressed: The compressed bzip2 data
Return Value:
1 on success, 0 on failure
5.35 Major Changes
Added ability to mark a function as public / private to restrict whether the function can be called from an MvDO. Using this feature will prevent the entire file / function from being run on older versions of the engine. Added optional "ACCESS" attribute to the MvFUNCTION tag that supports the following values:
"public": The function can be called from an MvDO
"private": The function cannot be called from an MvDO
If the "ACCESS" attribute is omitted or left blank, the function will be made public
Added compiler flag, -A, which will make all functions that do not explicitly set a function's "ACCESS" attribute to "public" private by default
Added the ability to log slow requests to the system log via the MvCONFIG_SLOWREQUEST_SYSLOG configuration settings
Mia now requires Windows 8 or higher
The template compiler now generates byte-code for entities instead of relying on the VM to parse named constants at runtime
5.34 Major Changes
The following libraries are now dynamically loaded and need to be registered as system libraries:
MySQL: A system library with code "MYSQLCLIENT" must be registered and point to the location of the MySQL client library
E.g. <SYSTEM-LIB CODE="MYSQLCLIENT" LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib">>
PostgreSQL: A system library with code "PQ" must be registered and point to the location of the PostgreSQL library
E.g. <SYSTEM-LIB CODE="PQ" LIBRARY="/usr/lib/libpq.dylib">
bzip2: A system library with code "BZ2" must be registered and point to the location of the bzip2 library
E.g. <SYSTEM-LIB CODE="BZ2" LIBRARY="/usr/lib/libbz2.dylib">
Added support for routing TCP requests through a SOCKS proxy server.
Added support for OpenSSL 1.1.x.
Added the ability to log slow requests to the system log via the MvCONFIG_SLOWREQUEST_SYSLOG configuration settings
Tag error messages such as g.MvOPENVIEW_Error, g.MvCALL_Error, and g.MvDO_Error no longer contain entity encoded values. The
MivaScript developer is now responsible for encoding any and all necessary values before outputting the data.
The FastCGI application now loads the MvCONFIG_LIBRARY environment variable from its own environment. This requires the
environment variable to be set prior to the FastCGI process being spawned.
The FastCGI application now uses the SCRIPT_NAME environment variable instead of the PATH_INFO environment variable when parsing
and executing the desired file path.
Spring 2018 Site updated to 5.32. Added Redis: Redis allows building advanced caching mechanisms into Miva Script applications.
8/8/2017 Site updated to 5.26, 5.27 and 5.28. The MvCall Page has better descriptions of the methods, links to more information and a few new examples.
9/19/2016, All function category assignments were re-evaluated and corrections made. A new category called Encoding was added below the String category and Inspection was moved below Strings. Also array and structure functions were removed from system and placed under the Array category.