Skip to content

empty() is NOT your friend for strings #22522

@PVince81

Description

@PVince81

Basically, empty(0) or empty('0') returns true...

% grep -rie "empty(.*path" apps lib core
apps/files_versions/lib/storage.php:                                            if (empty($userFullPath)) {
apps/files_sharing/lib/sharedstorage.php:               if (empty($path)) {
apps/files_sharing/lib/sharedstorage.php:               if (empty($path)) {
apps/user_ldap/lib/user/user.php:               if(!empty($path)) {
apps/files_trashbin/lib/trashbin.php:           if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
apps/files_trashbin/lib/trashbin.php:                   if (empty($ownerPath)) {
apps/files_external/3rdparty/Dropbox/API.php:           if(!empty($path)){
apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/Cookie/CookieParser.php:        if (empty($path) || substr($path, 0, 1) !== '/') {
lib/base.php:           if (!empty($config_paths)) {
lib/private/appframework/http/request.php:              if (!empty($path)) {
lib/private/helper.php:                         if (empty($paths)) {

And here with "name", probably less critical:

% grep -rie "empty(.*name" apps lib core
apps/dav/lib/carddav/converter.php:             $displayName = empty($displayName ) ? $uid : $displayName;
apps/dav/lib/carddav/converter.php:             if (!empty($displayName)) {
apps/dav/lib/carddav/converter.php:             $displayName = empty($displayName ) ? $uid : $displayName;
apps/dav/lib/comments/entitytypecollection.php:         if(empty($name) || !is_string($name)) {
apps/files_versions/lib/storage.php:            if (empty($filename)) {
apps/files_versions/lib/storage.php:                    if (empty($filename)) {
apps/files_sharing/lib/sharedmount.php:         if ($share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP && empty($share['unique_name'])) {
apps/user_ldap/lib/access.php:                  if(!isset($ldapName[0]) && empty($ldapName[0])) {
apps/user_ldap/lib/access.php:                  if(!empty($usernameAttribute)) {
apps/user_ldap/lib/user/user.php:               if(!empty($displayName)) {
apps/user_ldap/lib/user/user.php:               if(!empty($displayName2)) {
apps/user_ldap/lib/wizard.php:          if(empty($displayName)) {
apps/user_ldap/lib/wizard.php:          if(empty($displayName)) {
apps/files_external/lib/amazons3.php:           $params['hostname'] = empty($params['hostname']) ? 's3.amazonaws.com' : $params['hostname'];
apps/files_external/lib/swift.php:              if (empty($params['service_name'])) {
lib/private/urlgenerator.php:           } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
lib/private/urlgenerator.php:           } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
lib/private/setup/abstractdatabase.php:         if(empty($config['dbname'])) {
lib/private/setup/oci.php:              if(empty($config['dbname'])) {
lib/private/user/user.php:                      if (!empty($displayName)) {
lib/private/user/user.php:              if ($this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME) && !empty($displayName)) {
lib/private/systemtag/systemtagmanager.php:             if (!empty($nameSearchPattern)) {
lib/public/util.php:                    if(!empty($ccname)) {
core/command/config/system/getconfig.php:                       if (!empty($configNames)) {

@icewind1991 @nickvergessen @DeepDiver1975 @LukasReschke @schiesbn @rullzer @blizzz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions