Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commit feedc68

Browse files
committed
fixes #436 Illegal string offset and Invalid argument in FlashMessages
fixes #436 error occurs when trying to add message to messages when messages is not a valid array, permitted in php7.0 and earlier but not in php 7.1. Not reproduced but fixed by adding defensive code to ensure array is always initialised.
1 parent 09cbf1f commit feedc68

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Hyyan/WPI/Tools/FlashMessages.php

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public static function getOptionName()
132132
*/
133133
private static function getMessages()
134134
{
135+
$messages = get_option( static::getOptionName(), array() );
136+
if ( ! is_array( $messages ) ) {
137+
$messages = array();
138+
}
139+
return $messages;
135140
return get_option(static::getOptionName(), array());
136141
}
137142
}

0 commit comments

Comments
 (0)