Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Error: arrayValue is deprecated. Use val instead

I have been using Vanilla Forums (open source v2.3.1) for a while. All of a sudden I started getting the error "arrayValue is deprecated. Use val instead" on my forum. After investigation, I figured that it was related to several plugins. I removed them one by one and it resolved the error. But I lost several features, which were provided by those plugins.

I absolutely did not change anything on my forum for a while. So I was wondering if anything else could have changed on the host's side (like PHP version perhaps?)

Some of the plugins that had the issue are - OnlineNow, UserList, TopPosters and Signatures.

==========================

858: trigger_error($message, E_USER_ERROR);
859: return;
860: }
861: }
862: trigger_error($message, E_USER_DEPRECATED);
863: }
864: }
865:
866: if (!function_exists('explodeTrim')) {
Backtrace:
/home/myhome/public_html/library/core/functions.general.phpPHP::Gdn_ErrorHandler();
[/home/myhome/public_html/library/core/functions.general.php:862] PHP::trigger_error();
[/home/myhome/public_html/library/core/functions.deprecated.php:76] PHP::deprecated();
[/home/myhome/public_html/plugins/TopPosters/default.php:67] PHP::arrayValue();
[/home/myhome/public_html/plugins/TopPosters/default.php:59] TopPostersPlugin->_AttachBadge();
[/home/myhome/public_html/library/core/class.pluginmanager.php:873] TopPostersPlugin->DiscussionController_CommentInfo_Handler();
[/home/myhome/public_html/library/core/class.pluginmanager.php:781] Gdn_PluginManager->callEventHandler();
[/home/myhome/public_html/library/core/class.pluggable.php:133] Gdn_PluginManager->callEventHandlers();
[/home/myhome/public_html/applications/vanilla/views/discussion/helper_functions.php:148] Gdn_Pluggable->fireEvent();
[/home/myhome/public_html/applications/vanilla/views/discussion/comments.php:19] PHP::writeComment();
[/home/myhome/public_html/applications/vanilla/views/discussion/index.php:53] PHP::include();
[/home/myhome/public_html/library/core/class.controller.php:713] PHP::include();
[/home/myhome/public_html/library/core/class.controller.php:1242] Gdn_Controller->fetchView();
[/home/myhome/public_html/library/core/class.pluggable.php:199] Gdn_Controller->xRender();
[/home/myhome/public_html/applications/vanilla/controllers/class.discussioncontroller.php:282] Gdn_Pluggable->__call();
[/home/myhome/public_html/applications/vanilla/controllers/class.discussioncontroller.php:282] DiscussionController->render();
[/home/myhome/public_html/applications/vanilla/controllers/class.discussioncontroller.php:282] DiscussionController->index();
[/home/myhome/public_html/library/core/class.dispatcher.php:326] PHP::call_user_func_array();
[/home/myhome/public_html/index.php:44] Gdn_Dispatcher->dispatch();
Variables in local scope:
[oldName] 'arrayValue'
[newName] 'val'
[date] ''
[message] 'arrayValue is deprecated. Use val instead.'
Need Help?
If you are a user of this website, you can report this message to a website administrator.

If you are an administrator of this website, you can get help at the Vanilla Community Forums.

Additional information for support personnel:
Application: Vanilla
Application Version: 2.3.1
PHP Version: 5.6.33
Operating System: Linux
Server Software: Apache
Referer: https://www.mydomain.com/
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Controller: PHP
Method: trigger_error

Comments

  • RiverRiver MVP
    edited February 7

    @brainolution said:
    I have been using Vanilla Forums (open source v2.3.1) for a while. All of a sudden I started getting the error "arrayValue is deprecated. Use val instead" on my forum. After investigation, I figured that it was related to several plugins. I removed them one by one and it resolved the error. But I lost several features, which were provided by those plugins.

    I absolutely did not change anything on my forum for a while. So I was wondering if anything else could have changed on the host's side (like PHP version perhaps?)

    Some of the plugins that had the issue are - OnlineNow, UserList, TopPosters and Signatures.

    ==========================

    858: trigger_error($message, E_USER_ERROR);
    859: return;
    860: }
    861: }
    862: trigger_error($message, E_USER_DEPRECATED);
    863: }
    864: }
    865:
    866: if (!function_exists('explodeTrim')) {
    Backtrace:
    /home/myhome/public_html/library/core/functions.general.phpPHP::Gdn_ErrorHandler();
    [/home/myhome/public_html/library/core/functions.general.php:862] PHP::trigger_error();
    [/home/myhome/public_html/library/core/functions.deprecated.php:76] PHP::deprecated();
    [/home/myhome/public_html/plugins/TopPosters/default.php:67] PHP::arrayValue();
    [/home/myhome/public_html/plugins/TopPosters/default.php:59] TopPostersPlugin->_AttachBadge();

    I absolutely did not change anything on my forum for a while. So I was wondering if anything else could have changed on the host's side (like PHP version perhaps?)

    could it be you turned on debugging in config.php

    Set $Configuration['Debug'] = TRUE; in your conf/config.php to reveal full error messages. Remember to remove it when you are done. or

    set $Configuration['Debug'] = FALSE; in your conf/config.php if you don't want to see warning messages.

    if after turning off debug ....

    the error you reported relates to TopPosters.

    you might ask the question from the add-on (and from each add-on you see a problem.

    https://open.vanillaforums.com/addon/topposters-plugin

    As far as signatures - you could try github

    and see if it works

    https://github.com/vanilla/addons/tree/master/plugins/Signatures

    as far as the other plugins try them individually and see if you have errors.


    regarding deprecation and plugin changes....

    if the plugin author doesn't change it and you want here is further info... you can see parameters and arguments needed for each functions.

    deperecation info here...
    https://github.com/vanilla/vanilla/search?q=arrayvalue&type=

    the function prior to deprecation...
    https://github.com/vanilla/vanilla/blob/Vanilla_2.1/library/core/functions.general.php#L214

    this is arrayvalue
    213  
    214 if (!function_exists('ArrayValue')) { 
    215    /** 
    216     * Returns the value associated with the $Needle key in the $Haystack 
    217     * associative array or FALSE if not found. This is a CASE-SENSITIVE search. 
    218     * 
    219     * @param string The key to look for in the $Haystack associative array. 
    220     * @param array The associative array in which to search for the $Needle key. 
    221     * @param string The default value to return if the requested value is not found. Default is FALSE. 
    222     */ 
    223    function ArrayValue($Needle, $Haystack, $Default = FALSE) { 
    224       $Result = GetValue($Needle, $Haystack, $Default); 
    225         return $Result; 
    226    } 
    227 } 
    

    the new function ...

    https://github.com/vanilla/vanilla/blob/Vanilla_2.5/library/core/functions.compatibility.php#L399

    399 if (!function_exists('val')) { 
    400     /** 
    401      * Return the value from an associative array or an object. 
    402      * 
    403      * @param string $key The key or property name of the value. 
    404      * @param mixed $collection The array or object to search. 
    405      * @param mixed $default The value to return if the key does not exist. 
    406      * @return mixed The value from the array or object. 
    407      */ 
    408     function val($key, $collection, $default = false) { 
    409         if (is_array($collection)) { 
    410             if (array_key_exists($key, $collection)) { 
    411                 return $collection[$key]; 
    412             } else { 
    413                 return $default; 
    414             } 
    415         } elseif (is_object($collection) && property_exists($collection, $key)) { 
    416             return $collection->$key; 
    417         } 
    418         return $default; 
    419     } 
    420 } 
    

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • @River - Thanks for your help.

    I don't have the debug variable in my config.php, but I added it and set it to False. Let me clarify that these are not just warnings, but reported as "Fatal Error". I managed to resolve several of these errors by replacing the deprecated calls. However, I'm still not clear what triggered these errors all of a sudden. What has changed?

    Currently I'm stuck at this error with the UserList plugin and will post it on a new thread for that plugin (per your suggestion):

    Fatal Error in PHP.preg_match();
    preg_match() expects parameter 2 to be string, array given
    The error occurred on or near: /home/myhome/public_html/plugins/UserList/class.userlistmodule.php
    54: public function ToString() {
    55: $String = '';
    56: $Session = Gdn::Session();
    57: $permissions=$Session->User->Permissions;
    58: $admin=preg_match('/Garden.Settings.Manage/',$permissions);
    59:
    60: ob_start();
    61: $Limit = Gdn::Config('UserList.Limit');
    62: $Photo = Gdn::Config('UserList.Photo');

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Normally that shouldn't be errors but warnings. t could also be triggered by the PHP error level.

    Check a) if you have ini_set('display_errors', 0); in your /index.php and b) if your hoster has any way to overrule your settings, maybe by a php.ini that has been altered somewhere

  • Thanks, @R_J

    I worked with my host to turn off display_errors setting and can see both the local value and the master value set to "off" in mydomain.com/phpinfo.php .

    I'm also getting another warning in a pop-up when saving drafts -

    { "Code": 16384, "Exception": "DraftModel->getCount(int) is deprecated. Use DraftModel->getCountByUser() instead.", "Class": "Gdn_ErrorException" }

    The above warning is also discussed in the thread: https://open.vanillaforums.com/discussion/33009/strange-error-whit-2-3

    But it talks about the same fix that you mentioned.

    Is there anything else that I can check?

  • A quick update, if I remove my own php.ini, the errors are resolved. In the php.ini, display_errors = Off and error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT .

    Is there anything else that I can check?

  • RiverRiver MVP
    edited February 10

    @brainolution said:
    A quick update, if I remove my own php.ini, the errors are resolved. In the php.ini, display_errors = Off and error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT .

    Is there anything else that I can check?

    if you are saying everything works fine when you remove your php.ini you don't get errors.
    and you are satisfied.

    you can try this in your php.ini and see if it gives you desired results.

    error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);

    http://php.net/manual/en/errorfunc.constants.php

    if you still have issues - you could experiment and see if things work properly if you remove
    E_USER_ERROR. although leave it in if results are ok.

    • you can see samples of how to check ini settings here

    http://php.net/manual/en/function.ini-set.php

    e.g. from link

    <?php
    
    // This will NOT determine the success of ini_set(), instead
    // it only tests if the old value had been equivalent to false
    if ( !ini_set( 'display_errors', '1' ) ) 
        throw new \Exception( 'Unable to set display_errors.' );
    
    // This is the CORRECT way to determine success
    if ( ini_set( 'display_errors', '1' ) === false ) 
        throw new \Exception( 'Unable to set display_errors.' );    
    
    ?>
    

    http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors

    http://php.net/manual/en/function.error-reporting.php

    • the other thing you might do is upgrade to current version of vanilla 2.5 and PHP 7.2

    https://open.vanillaforums.com/discussion/35687/vanilla-2-5-is-now-available
    https://open.vanillaforums.com/discussion/35686/vanilla-will-end-php-5-6-support-in-2018

    instead of banging your head on an old version of vanilla and old version of php.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • RiverRiver MVP
    edited February 11

    is this what you have in your index.php?

    error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);

    regarding my last comment

    you can try this in your php.ini and see if it gives you desired results.
    
    error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);
    

    rather use this with =

    error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR

    phpinfo should tell you your error reporting as it understands it the location of the php.ini files it reads.

    you can use the values and total them to reflect what they are vs. what you think they are.

    http://uk.php.net/manual/en/errorfunc.constants.php

    https://stackoverflow.com/questions/3758418/numeric-values-of-error-reporting-levels

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • Things had been working fine without php.ini . But I still went ahead and upgraded to Vanilla 2.5.1 and PHP 7.2 without the php.ini . It continues to look good. Is there any strong reason to have a custom php.ini for which I should restore it back?

  • @brainolution said:
    Is there any strong reason to have a custom php.ini for which I should restore it back?

    the only reason would be if you want to modify existing settings within your own .ini file.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

Sign In or Register to comment.