[TYPO3-core] RFC:#1960: t3lib_BEfunc::blindUserNames() does not work sometimes

Oliver Klee typo3-german-02 at oliverklee.de
Fri May 28 20:24:56 CEST 2010


Hi,

+1 by reading with the following changes:

- Please add the class file to the autoload file.

> +/**
> + * Class that hooks into TCEmain and listens for updates to users and usergroups
> + * to update the cached usergroup l8ist

l8ist -> list

Please add a full stop at the end of the sentence.

Actually, I find the sentence hard to understand. Could you split it up?

> +	/**
> +	 * waits for TCEmain commands and looks for changed pages, if found further
> +	 * changes take place to determine whether the cache needs to be updated

Could you please use a full stop between these two sentences (and an
uppercase letter for the first word, and a full stop at the end)?

Ditto for the other function comments.

> +	 * @param	string	the DB table the operation was carried out on

the table -> the name of the table

> +	 * @param	string	TCEmain operation status, either 'new' or 'update'
> +	 * @param	string	the DB table the operation was carried out on
> +	 * @param	mixed	the record's uid for update records, a string to look the record's uid up after it has been created
> +	 * @param	array	array of changed fiels and their new values
> +	 * @param	t3lib_TCEmain	TCEmain parent object
> +	 */
> +	public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, t3lib_TCEmain $tceMain) {
> +		if ($table == 'be_users') {
> +			$this->processUpdateUsers($recordId);
> +		} elseif ($table == 'be_groups') {
> +			$this->processUpdateUsergroups();
> +		}
> +	}

Actually, you're using only the second parameter. So you can drop all
parameters starting from the third from the parameter list.

Ditto for the other functions.

> +	protected function processUpdateUsergroups() {
> +		$userAuthGroupObj = t3lib_div::makeInstance('t3lib_userAuthGroup');
> +		$userAuthGroupObj->user_table = 'be_users';
> +
> +		$users = t3lib_BEfunc::getUserNames();
> +		foreach($users as $user) {

Please add the missing space after foreach.

> +	/**
> +	 * Update the cached usergroup list of a given user
> +	 *
> +	 * @param	int		Id of the user
> +	 * @return	void
> +	 */
> +	protected function processUpdateUsers($userId) {
> +		$userAuthGroupObj = t3lib_div::makeInstance('t3lib_userAuthGroup');
> +		$userAuthGroupObj->user_table = 'be_users';
> +		$userAuthGroupObj->setBeUserByUid(intval($userId));
> +		$userAuthGroupObj->fetchGroupData();
> +	}

int -> integer

As $userId is required to be an integer (as per the documentation), you
need to move the intval to the caller.

Please document whether this functions requires a user with that UID to
exist.


Actually, both protected functions should share some code (with the
second being a special case with a one-element array) so you can avoid
the code duplication, making the class easier to maintain.


Oli
-- 
Certified TYPO3 Integrator | TYPO3 Security Team Member


More information about the TYPO3-team-core mailing list