Skip to content

Bug: calling countAllResults after find($id) produce wrong result #2705

Description

@arif-rh

Describe the bug

calling countAllResults after find($id) produce wrong result. for example, I made below tests:

    public function testFindIdCountAllResults()
	{
		$model = new UserModel($this->db);

		$model->find(1);

		$this->assertEquals(1, $model->countAllResults());
	}

	public function testFindArrayCountAllResults()
	{
		$model = new UserModel($this->db);

		$model->find([1,2]);

		$this->assertEquals(2, $model->countAllResults());
	}

and both produce an error, because all countAllResults is 4

find countAllResults

This issue only happen when we passing $id to find method. If we omit it, it will work fine, because without passing $id it will call findAll instead.

CodeIgniter 4 version

4.0.2

Affected module(s)

CodeIgniter\Model

Expected behavior, and steps to reproduce if appropriate

Make test as description above to reproduce the issue

Context

  • OS: Windows 10
  • Web server Apache 2.4.37
  • PHP version 7.3.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions